Sobes.tech
Middle

What CI/CD tools have you used in your projects?

sobes.tech AI

Answer from AI

In my projects, I actively used the following CI/CD tools:

  • Version control systems (SCM):
    • Git (with remote repositories on GitLab, GitHub, Bitbucket)
  • Build systems:
    • Maven
    • Gradle
  • CI/CD servers:
    • Jenkins (most often with Pipeline as Code - Jenkinsfile)
    • GitLab CI/CD
    • GitHub Actions
  • Static code analysis tools:
    • SonarQube
  • Testing tools:
    • JUnit
    • Mockito
    • Spring Boot Test
    • Selenium (for UI tests)
  • Dependency management tools:
    • Nexus Repository Manager
    • Artifactory
  • Containerization and orchestration tools:
    • Docker
    • Kubernetes
  • Deployment tools:
    • Ansible
    • Terraform

A typical CI/CD pipeline included the following stages:

  1. Trigger build on push to master or pull request.
  2. Fetch source code.
  3. Build the project (Maven/Gradle).
  4. Run unit and integration tests.
  5. Static code analysis (SonarQube).
  6. Create Docker image.
  7. Push Docker image to registry.
  8. Deploy (to testing/staging/production environment).
  9. Run smoke/e2e tests.

Here is an example of a simple Jenkinsfile for a Maven project:

pipeline {
    agent any

    stages {
        stage('Checkout') {
            steps {
                git 'https://github.com/your/repo.git' // Replace with your repo URL
            }
        }
        stage('Build') {
            steps {
                sh 'mvn clean package -DskipTests' // Build the project
            }
        }
        stage('Test') {
            steps {
                sh 'mvn test' // Run unit tests
            }
        }
        stage('SonarQube Analysis') {
            // Assuming SonarQube server is configured in Jenkins
            steps {
                withSonarQubeEnv('Your SonarQube Server Name') {
                    sh 'mvn sonar:sonar' // Run SonarQube analysis
                }
            }
        }
        stage('Build Docker Image') {
            steps {
                script {
                    docker.build("your-docker-repo/your-image:${env.BUILD_NUMBER}") // Build Docker image
                }
            }
        }
        stage('Push Docker Image') {
            steps {
                script {
                    docker.withRegistry('https://your-docker-registry', 'your-registry-credential-id') {
                        docker.image("your-docker-repo/your-image:${env.BUILD_NUMBER}").push() // Push Docker image
                    }
                }
            }
        }
        stage('Deploy') {
            steps {
                // Add deployment steps here (e.g., using kubectl, Ansible, etc.)
                echo 'Deploying application...'
            }
        }
    }
    post {
        always {
            echo 'Pipeline finished.'
        }
        failure {
            echo 'Pipeline failed.'
        }
        success {
            echo 'Pipeline succeeded.'
        }
    }
}