Skip to content
DevOps Praxis30 min read2025-06-12

CI/CD PipelinesGitHub Actions, Jenkins & GitLab CI

Fully automated deployment pipelines with GitHub Actions, Jenkins and GitLab CI - concepts, comparison and best practices for modern software development.

CI/CDGitHub ActionsJenkinsGitLab CIDevOps

What is CI/CD?

Continuous Integration (CI) and Continuous Delivery/Deployment (CD) are practices that aim to speed up and improve the software development process through automation. A CI/CD pipeline automates the steps from a code change to delivery to the users.

  • Continuous Integration (CI): Developers regularly integrate code into a central repository. Each push triggers an automated build and test.
  • Continuous Delivery (CD): Extension of CI in which code changes are automatically deployed to a production-like environment (staging). Deployment to production is done manually.
  • Continuous Deployment (CDP): Every code change that passes all tests is automatically deployed to production.

GitHub Actions GitHub Actions

GitHub Actions is a CI/CD platform that is integrated directly into GitHub. Workflows are defined in YAML files and can react to events in the repository (e.g. push, pull request).

Example workflow (Node.js):

name: Node.js CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Use Node.js
      uses: actions/setup-node@v3
      with:
        node-version: '18.x'
    - run: npm ci
    - run: npm run build --if-present
    - run: npm test

Advantages:

  • Deep integration with GitHub repositories.
  • Large selection of ready-made promotions in the Marketplace.
  • Support for Linux, macOS, Windows, ARM and containers.
  • Generous free contingents for public and private repos.

Jenkins

Jenkins is a widely used open-source automation server. It is extremely flexible and extensible through thousands of plugins. Pipelines can be defined via the UI (classic) or as code (Jenkinsfile).

Example Jenkinsfile (declarative pipeline):

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                sh 'npm install'
                sh 'npm run build'
            }
        }
        stage('Test') {
            steps {
                sh 'npm test'
            }
        }
        stage('Deploy') {
            steps {
                echo 'Deploying...'
                // Deploy steps here
            }
        }
    }
}

Advantages:

  • Very high flexibility and adaptability.
  • Huge community and plugin ecosystem.
  • On-premise or cloud deployment possible.
  • Supports complex and distributed builds.

GitLab CI/CD

GitLab CI/CD is deeply integrated into the GitLab platform and offers a comprehensive DevOps solution from a single source. Pipelines are defined in a `.gitlab-ci.yml` file in the repository.

Example .gitlab-ci.yml:

image: node:18

stages:
  - build
  - test
  - deploy

build_job:
  stage: build
  script:
    - npm install
    - npm run build

test_job:
  stage: test
  script:
    - npm test

deploy_job:
  stage: deploy
  script:
    - echo "Deploying application..."
    # Deploy scripts here
    only:
    - main # Only deploy on the main branch

Advantages:

  • Seamless integration into the GitLab workflow (issues, merge requests, registry).
  • Built-in container registry and Kubernetes integration.
  • Auto DevOps for automatic pipeline creation.
  • Available as SaaS (GitLab.com) or self-managed.

Tools compared

KriteriumGitHub ActionsJenkinsGitLab CI
HostingCloud (GitHub)Self-Managed / CloudCloud (GitLab) / Self-Managed
ConfigurationYAMLGroovy (Jenkinsfile) / UIYAML
IntegrationVery good with GitHubExtremely many pluginsVery good with GitLab
Kosten (Basis)Free for public repos, freemium for private reposOpen Source (kostenlos)Free for public repos, freemium for private repos

Pipeline Phasen

A typical CI/CD pipeline consists of several phases:

  1. Source: Code changes are pushed to the repository.
  2. Build: The code is compiled, artifacts are created.
  3. Test: Automated tests (unit, integration, etc.) are executed.
  4. Deploy (Staging): The application is deployed to a test environment.
  5. Deploy (Production): (After manual or automatic approval) The application is deployed to the production environment.

best practices

  • Pipeline as Code: Definiere Pipelines in versioniertem Code (z.B. YAML, Jenkinsfile).
  • Fast feedback: Optimize pipelines for short throughput times.
  • Atomic builds: Every build should be a potentially shippable increment.
  • Comprehensive test automation: Confidence in the pipeline through good test coverage.
  • Secrets Management: Secure management of passwords and keys.
  • Monitoring: Monitor both the pipeline and the deployed application.
  • Idempotent deployments: Repeated deployments should lead to the same result.

DevSecOps in CI/CD

DevSecOps integrates security practices ("security as code") into every phase of the CI/CD pipeline:

  • Static Application Security Testing (SAST): Code analysis for vulnerabilities.
  • Software Composition Analysis (SCA): Checking dependencies.
  • Dynamic Application Security Testing (DAST): Tests of the running application.
  • Container Image Scanning: Security check of Docker images.
  • Infrastructure as Code (IaC) Scanning: Checking Terraform, CloudFormation etc.