Skip to main content
GitHub Actions and Jenkins share many CI/CD concepts, so migrating pipelines is usually a matter of translating declarative constructs. This guide compares common Jenkins Declarative Pipeline directives with their GitHub Actions equivalents and provides concise, copy-ready examples to accelerate migration.
A diagram titled "Pipeline Structure" showing Jenkins and GitHub Actions at the top feeding into a CI/CD pipeline. The pipeline includes stages labeled Building, Tests, publish, Release, and Deployment.
Overview
  • Jenkins Declarative Pipelines are Groovy-based and organized into top-level sections such as agent, environment, and stages.
  • GitHub Actions workflows use YAML organized under on, jobs, env, defaults, and permissions.
  • Conceptual mappings:
    • Jenkins stages → GitHub Actions jobs
    • Jenkins steps → GitHub Actions steps (nested under a job)
    • Jenkins agent → GitHub Actions runs-on (and optionally container)
Quick mapping table Links and references
  1. Top-level pipeline → jobs
Jenkins declarative pipeline (Groovy):
Equivalent GitHub Actions workflow (YAML):
Jenkins stages are often sequential by default. In GitHub Actions, implement sequential phases by introducing job dependencies (using needs), or keep multiple sequential steps inside one job.
  1. Agents, runners, and containers
Mappings at a glance:
  • Jenkins agent anyruns-on: ubuntu-latest
  • Jenkins agent { label 'docker' }runs-on: [self-hosted, docker]
  • Jenkins agent { docker { image 'alpine' } }container: alpine (inside a job)
Jenkins example:
GitHub Actions equivalent (runs the job inside a Node container on a GitHub-hosted runner):
Explanation:
  • runs-on provisions the VM environment; container launches the specified container image inside that VM. All steps run within the container.
  1. Environment variables
Jenkins:
GitHub Actions (workflow-level and job-level env):
Notes:
  • Use env at the workflow level to set variables available to all jobs, and at job or step level for narrower scope.
  1. Credentials and secrets
Jenkins with withCredentials:
GitHub Actions (use repository or organization secrets):
Never print secrets to logs. In GitHub Actions, reference secrets using ${{ secrets.YOUR_SECRET }} and avoid echoing them. Masked secrets are protected, but logging them exposes risk.
  1. Conditional execution
Jenkins example using when:
GitHub Actions uses if at the job or step level:
Example: condition on PR comment body
  1. Parallelism and matrix builds
Jenkins parallel stages:
GitHub Actions matrix strategy: run the same job across multiple OSes and Node versions
Notes:
  • GitHub Actions runs jobs in parallel by default. Use strategy.matrix for multiple configurations inside one logical job.
  1. Triggers
Jenkins triggers example (cron):
GitHub Actions equivalents:
  • Scheduled runs:
  • Manual trigger (adds “Run workflow” button):
  • Event-based triggers with filters:
Summary and migration checklist These mappings cover the core patterns you’ll use when migrating Jenkins Declarative Pipelines to GitHub Actions workflows. For advanced migrations (pipeline libraries, custom shared libraries, or scripted pipelines), consider breaking large Groovy logic into smaller scripts or actions and leveraging reusable workflows in GitHub Actions. Further reading

Watch Video