Sobes.tech
Junior

What tools do you know for continuous integration and delivery (CI/CD)?

sobes.tech AI

Answer from AI

Jenkins, GitLab CI, GitHub Actions, CircleCI, TeamCity, Azure DevOps Pipelines, Bamboo, Travis CI.

Main categories of CI/CD tools:

  • Full-cycle platforms: Provide comprehensive solutions including repository management, CI, CD, monitoring, and other features.
    • GitLab (GitLab CI)
    • GitHub (GitHub Actions)
    • Azure DevOps
  • General-purpose CI/CD tools: Flexible systems that can be integrated with various tools for building, testing, and deploying.
    • Jenkins
    • CircleCI
    • Bamboo
    • TeamCity
    • Travis CI
  • Build systems: Focused on automating the compilation, testing, and packaging of code.
    • Maven
    • Gradle
    • Ant
  • Deployment tools: Specialize in automating the delivery of applications to various environments.
    • Ansible
    • Chef
    • Puppet
    • Spinnaker
    • Argo CD

Example Jenkinsfile configuration for a simple CI pipeline:

// Dockerfile
FROM openjdk:11-jre-slim
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
// Jenkinsfile
pipeline {
    agent any 
    
    stages {
        stage('Build') {
            steps {
                sh 'mvn clean package' // Build the application with Maven
            }
        }
        stage('Test') {
            steps {
                sh 'mvn test' // Run tests
            }
        }
        stage('Build Docker Image') {
            steps {
                script { // Create Docker image
                    docker.build("my-app:${env.BUILD_ID}") 
                }
            }
        }
        stage('Deploy') {
            steps {
                // Deployment steps, e.g., on Kubernetes
                echo "Deploying image my-app:${env.BUILD_ID}..."
            }
        }
    }
}

Example GitLab CI configuration for a similar pipeline:

# .gitlab-ci.yml
image: maven:latest # Using Maven image

stages:
 - build
 - test
 - docker_build
 - deploy

build:
  stage: build
  script:
    - mvn clean package -B # Build the application with Maven in batch mode

test:
  stage: test
  script:
    - mvn test -B # Run tests in batch mode

docker_build:
  stage: docker_build
  image: docker:latest # Using Docker image
  services:
    - docker:dind # Run Docker-in-Docker service
  variables:
    DOCKER_HOST: tcp://docker:2375 # Environment variable for Docker access
    DOCKER_TLS_CERTDIR: "" # Disable TLS
  script:
    - docker build -t my-app:$CI_COMMIT_SHORT_SHA . # Build Docker image
    - docker push my-app:$CI_COMMIT_SHORT_SHA # Push image to repository

deploy:
  stage: deploy
  script:
    - echo "Deploying image my-app:$CI_COMMIT_SHORT_SHA..."
  only:
    - main # Run only on push to main branch