
- 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
| Jenkins concept | GitHub Actions equivalent | Notes / example |
|---|---|---|
pipeline / stages | workflow / jobs | Jobs run independently; use job dependencies to sequence. |
agent | runs-on / container | Example: runs-on: ubuntu-latest or container: node:18. |
environment | env | Use workflow-level or job-level env. |
withCredentials | ${{ secrets.* }} | Store secrets in repo/org settings. |
when | if | if works at job or step level. |
| Parallel stages | parallel jobs or strategy.matrix | Matrix runs are ideal for multiple configs. |
Triggers / cron | on (schedule, push, workflow_dispatch) | Use on.schedule for cron-based runs. |
- 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:
| Step | Action |
|---|---|
| Convert high-level structure | Map Jenkins stages to GitHub jobs; use needs to sequence jobs. |
| Choose runners | Replace agent with runs-on and container as required. |
| Move secrets | Migrate credentials to GitHub secrets and reference with ${{ secrets.* }}. |
| Translate conditional logic | Convert when blocks to if: expressions at job/step level. |
| Parallelize | Use multiple jobs or strategy.matrix for parallel/matrix runs. |
| Set triggers | Replace Jenkins triggers with on: schedule, workflow_dispatch, or event filters. |
- 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/