
- Jenkins Declarative Pipelines are Groovy-based and organized into top-level sections such as
agent,environment, andstages. - GitHub Actions workflows use YAML organized under
on,jobs,env,defaults, andpermissions. - Conceptual mappings:
- Jenkins
stages→ GitHub Actionsjobs - Jenkins
steps→ GitHub Actionssteps(nested under ajob) - Jenkins
agent→ GitHub Actionsruns-on(and optionallycontainer)
- Jenkins
Links and references
- Jenkins Declarative Pipeline: https://www.jenkins.io/doc/book/pipeline/
- GitHub Actions: https://docs.github.com/actions
- Top-level pipeline → jobs
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.- Agents, runners, and containers
- Jenkins
agent any→runs-on: ubuntu-latest - Jenkins
agent { label 'docker' }→runs-on: [self-hosted, docker] - Jenkins
agent { docker { image 'alpine' } }→container: alpine(inside a job)
runs-onprovisions the VM environment;containerlaunches the specified container image inside that VM. All steps run within the container.
- Environment variables
env):
- Use
envat the workflow level to set variables available to all jobs, and at job or step level for narrower scope.
- Credentials and secrets
withCredentials:
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.- Conditional execution
when:
if at the job or step level:
- Parallelism and matrix builds
- GitHub Actions runs jobs in parallel by default. Use
strategy.matrixfor multiple configurations inside one logical job.
- Triggers
- Scheduled runs:
- Manual trigger (adds “Run workflow” button):
- Event-based triggers with filters:
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
- GitHub Actions concepts: https://docs.github.com/actions/learn-github-actions/introduction-to-github-actions
- Jenkins Pipeline Syntax: https://www.jenkins.io/doc/book/pipeline/syntax/