TExcelTAD
Home › CI/CD Pipelines & Pipeline Security › Toolkit: Jenkins, Azure Pipelines, act & gitlab-ci-local

Toolkit: Jenkins, Azure Pipelines, act & gitlab-ci-local

GitHub Actions and GitLab CI cover most new projects, but a DevOps engineer meets other systems in existing companies, and needs tools to run pipelines locally. This lesson is a field guide: enough of each to read, change and debug a pipeline written in it.

The landscape

System Defined in Hosted / self-hosted Where you meet it
Jenkins Jenkinsfile (Groovy DSL) self-hosted server + agents enterprises, on-prem, game studios, long-lived setups
Azure Pipelines azure-pipelines.yml Microsoft-hosted or self-hosted agents Microsoft and .NET shops, Azure DevOps users
CircleCI, Buildkite, Bitbucket Pipelines, TeamCity YAML (Kotlin DSL for TeamCity) SaaS, hybrid startups (CircleCI), large monorepos (Buildkite), Atlassian shops
Tekton, Argo Workflows Kubernetes CRDs in your cluster platform teams building CI on Kubernetes
Dagger code (Go, Python, TypeScript) running containers anywhere "pipelines as real code" that run the same locally and in any CI

The concepts from Anatomy of a Pipeline carry over unchanged; GitLab CI & Jenkins has a concept-by-concept table across GitHub, GitLab and Jenkins.

Jenkins

Jenkins is a Java server whose features come from plugins. Modern Jenkins jobs are Multibranch Pipelines that read a Jenkinsfile from each branch. A declarative pipeline for the lint → test → build → scan → push → deploy flow (non-run):

groovy
// Jenkinsfile
pipeline {
  agent { label 'linux && docker' }
  options {
    timeout(time: 30, unit: 'MINUTES')
    disableConcurrentBuilds()
    buildDiscarder(logRotator(numToKeepStr: '30'))
  }
  environment {
    IMAGE = "registry.example.com/acme/shop"
  }
  stages {
    stage('Lint & test') {
      parallel {
        stage('Lint') { steps { sh 'make lint' } }
        stage('Unit') {
          steps { sh 'make test' }
          post { always { junit 'report.xml' } }       // test results in the UI
        }
      }
    }
    stage('Build & scan') {
      steps {
        sh 'docker build -t "$IMAGE:$GIT_COMMIT" .'
        sh 'trivy image --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1 "$IMAGE:$GIT_COMMIT"'
      }
    }
    stage('Push') {
      when { branch 'main' }
      steps {
        withCredentials([usernamePassword(credentialsId: 'registry', usernameVariable: 'REG_USER', passwordVariable: 'REG_PASS')]) {
          sh 'echo "$REG_PASS" | docker login registry.example.com -u "$REG_USER" --password-stdin'
          sh 'docker push "$IMAGE:$GIT_COMMIT"'
        }
      }
    }
    stage('Deploy production') {
      when { branch 'main' }
      input { message 'Deploy to production?'; submitter 'release-managers' }
      steps { sh './ci/deploy.sh production "$IMAGE:$GIT_COMMIT"' }
    }
  }
  post {
    failure { echo "notify the team here (Slack, email plugins)" }
    always  { sh 'docker logout registry.example.com || true' }
  }
}

Things that are different from YAML-based systems:

  • Agents are often persistent: workspaces, Docker images and credentials survive between builds unless you clean them (cleanWs(), ephemeral agents from the Kubernetes or EC2 plugins).
  • Credentials live in Jenkins' credential store and are injected with withCredentials; Jenkins masks them in the console log, with the same limits as GitHub's masking (Secrets).
  • Single quotes in sh '…' let the shell expand variables; Groovy double quotes interpolate before the shell runs, Jenkins' version of script injection.
  • Plugins are the attack surface and the upgrade burden: pin them, update them deliberately, and keep the controller off the internet where possible.

Azure Pipelines

Azure Pipelines (part of Azure DevOps) uses YAML with stages → jobs → steps, plus deployment jobs that target environments with approvals and checks, and built-in deployment strategies (non-run):

yaml
# azure-pipelines.yml
trigger:
  branches:
    include: [main]
pr:
  branches:
    include: [main]

variables:
  imageName: acme/shop

stages:
  - stage: Build
    jobs:
      - job: test_and_build
        pool:
          vmImage: ubuntu-24.04
        steps:
          - script: make lint test
            displayName: Lint and test
          - task: Docker@2
            displayName: Build and push
            inputs:
              command: buildAndPush
              containerRegistry: acme-registry          # a service connection
              repository: $(imageName)
              tags: $(Build.SourceVersion)

  - stage: Production
    dependsOn: Build
    condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
    jobs:
      - deployment: deploy
        environment: production                       # approvals and checks are configured on the environment
        pool:
          vmImage: ubuntu-24.04
        strategy:
          canary:
            increments: [10, 50]
            deploy:
              steps:
                - script: ./ci/deploy.sh production $(imageName):$(Build.SourceVersion) $(strategy.increment)
            on:
              failure:
                steps:
                  - script: ./ci/rollback.sh production

Mapping to what you know: service connections hold credentials for registries and clouds (with workload identity federation, the OIDC equivalent); environments carry approvals and checks; strategy supports runOnce, rolling and canary for deployment jobs; variable groups (optionally linked to Azure Key Vault) are the shared secrets.

act: GitHub Actions on your machine

act runs .github/workflows/ jobs in Docker containers that imitate GitHub's runners. It needs Docker and pulls large images, so it doesn't run in this course's sessions. Typical use (sample session):

bash
act -l                                        # list jobs and their events
act pull_request -j test                      # run the test job as for a PR
act workflow_dispatch -W .github/workflows/deploy.yml --input target=staging
act -s GITHUB_TOKEN="$(gh auth token)" --var REGISTRY=ghcr.io

Its runner images are smaller than GitHub's, and environments, OIDC, caches and service containers behave differently or partly, so use act to iterate on YAML and scripts, not as proof that a workflow works on GitHub. Release Engineering's Toolkit lists more of its limits. For static checks of workflow files, actionlint (syntax, expressions, ShellCheck inside run:) and zizmor (security problems such as injection and dangerous triggers) run in seconds and catch most mistakes before any push.

gitlab-ci-local: GitLab pipelines on your machine

You've used it all through the GitLab section. Three more options make it a daily tool: --needs to run a job together with what it needs, --variable for one-off values, and a .gitlab-ci-local-variables.yml for local stand-ins of CI/CD variables (keep it out of Git):

bash · try it yourself
mkdir shop && cd shop && git init -q
git commit -q --allow-empty -m "init"
git remote add origin https://gitlab.example.com/acme/shop.git
git update-ref refs/remotes/origin/main HEAD && git remote set-head origin main
cat > .gitlab-ci.yml <<'YML'
stages: [build, test, deploy]
build:
  stage: build
  script: [echo "build for $TARGET_ENV"]
unit:
  stage: test
  script: [echo "unit tests"]
deploy:
  stage: deploy
  needs: [build]
  script:
    - echo "deploy to $TARGET_ENV with token ${DEPLOY_TOKEN:0:4}..."
YML
cat > .gitlab-ci-local-variables.yml <<'YML'
DEPLOY_TOKEN: local-fake-token
TARGET_ENV: dev
YML
echo ".gitlab-ci-local-variables.yml" > .gitignore
git add .gitlab-ci.yml .gitignore && git commit -qm "ci"
gitlab-ci-local --needs deploy 2>&1 | grep ' > '
gitlab-ci-local --needs deploy --variable TARGET_ENV=staging 2>&1 | grep ' > '
build  > build for dev
deploy > deploy to dev with token loca...
build  > build for staging
deploy > deploy to staging with token loca...

--needs deploy ran build and deploy and skipped unit, which deploy doesn't need; the variables file supplied the token, and --variable overrode TARGET_ENV for one run. Limits to remember from this course: jobs with image: need Docker, and workflow:rules were not evaluated in testing (needs, rules & workflow:rules).

Test yourself

In Azure Pipelines, where are production approvals configured?

  1. In the YAML step
  2. On the environment that the deployment job targets
  3. In the service connection
  4. In the pool

Why is a passing act run not proof that the workflow works on GitHub?

  1. act uses a different YAML parser
  2. Its runner images and features (OIDC, environments, caches, services) differ from GitHub's
  3. act skips all steps
  4. act needs a GitHub login

What does gitlab-ci-local --needs deploy run?

  1. Every job
  2. deploy and the jobs it needs
  3. Only deploy
  4. Only the deploy stage