Skip to main content

This version of GitHub Enterprise was discontinued on 2023-01-18. No patch releases will be made, even for critical security issues. For better performance, improved security, and new features, upgrade to the latest version of GitHub Enterprise. For help with the upgrade, contact GitHub Enterprise support.

Migrating from Jenkins to GitHub Actions

GitHub Actions and Jenkins share multiple similarities, which makes migration to GitHub Actions relatively straightforward.

Note: GitHub-hosted runners are not currently supported on GitHub Enterprise Server. You can see more information about planned future support on the GitHub public roadmap.

Introduction

Jenkins and GitHub Actions both allow you to create workflows that automatically build, test, publish, release, and deploy code. Jenkins and GitHub Actions share some similarities in workflow configuration:

  • Jenkins creates workflows using Declarative Pipelines, which are similar to GitHub Actions workflow files.
  • Jenkins uses stages to run a collection of steps, while GitHub Actions uses jobs to group one or more steps or individual commands.
  • Jenkins and GitHub Actions support container-based builds. For more information, see "Creating a Docker container action."
  • Steps or tasks can be reused and shared with the community.

For more information, see "Core concepts for GitHub Actions."

Key differences

  • Jenkins has two types of syntax for creating pipelines: Declarative Pipeline and Scripted Pipeline. GitHub Actions uses YAML to create workflows and configuration files. For more information, see "Workflow syntax for GitHub Actions."
  • Jenkins deployments are typically self-hosted, with users maintaining the servers in their own data centers. GitHub Actions offers a hybrid cloud approach by hosting its own runners that you can use to run jobs, while also supporting self-hosted runners. For more information, see About self-hosted runners.

Comparing capabilities

Distributing your builds

Jenkins lets you send builds to a single build agent, or you can distribute them across multiple agents. You can also classify these agents according to various attributes, such as operating system types.

Similarly, GitHub Actions can send jobs to GitHub-hosted or self-hosted runners, and you can use labels to classify runners according to various attributes. For more information, see "Understanding GitHub Actions" and "About self-hosted runners."

Using sections to organize pipelines

Jenkins splits its Declarative Pipelines into multiple sections. Similarly, GitHub Actions organizes its workflows into separate sections. The table below compares Jenkins sections with the GitHub Actions workflow.

Jenkins DirectivesGitHub Actions
agentjobs.<job_id>.runs-on
jobs.<job_id>.container
post
stagesjobs
stepsjobs.<job_id>.steps

Using directives

Jenkins uses directives to manage Declarative Pipelines. These directives define the characteristics of your workflow and how it will execute. The table below demonstrates how these directives map to concepts within GitHub Actions.

Jenkins DirectivesGitHub Actions
environmentjobs.<job_id>.env
jobs.<job_id>.steps[*].env
optionsjobs.<job_id>.strategy
jobs.<job_id>.strategy.fail-fast
jobs.<job_id>.timeout-minutes
parametersinputs
outputs
triggerson
on.<event_name>.types
on.<push>.<branches|tags>
on.<pull_request>.<branches>
on.<push|pull_request>.paths
triggers { upstreamprojects() }jobs.<job_id>.needs
Jenkins cron syntaxon.schedule
stagejobs.<job_id>
jobs.<job_id>.name
toolsSpecifications for GitHub-hosted runners
inputinputs
whenjobs.<job_id>.if

Using sequential stages

Parallel job processing

Jenkins can run the stages and steps in parallel, while GitHub Actions currently only runs jobs in parallel.

Jenkins ParallelGitHub Actions
paralleljobs.<job_id>.strategy.max-parallel

Matrix

Both GitHub Actions and Jenkins let you use a matrix to define various system combinations.

JenkinsGitHub Actions
axisstrategy/matrix
context
stagessteps-context
excludes

Using steps to execute tasks

Jenkins groups steps together in stages. Each of these steps can be a script, function, or command, among others. Similarly, GitHub Actions uses jobs to execute specific groups of steps.

JenkinsGitHub Actions
stepsjobs.<job_id>.steps

Examples of common tasks

Scheduling a pipeline to run with cron

Jenkins Pipeline GitHub Actions Workflow
pipeline {
  agent any
  triggers {
    cron('H/15 * * * 1-5')
  }
}
on:
  schedule:
    - cron: '*/15 * * * 1-5'

Configuring environment variables in a pipeline

Jenkins Pipeline GitHub Actions Workflow
pipeline {
  agent any
  environment {
    MAVEN_PATH = '/usr/local/maven'
  }
}
jobs:
  maven-build:
    env:
      MAVEN_PATH: '/usr/local/maven'

Building from upstream projects

Jenkins Pipeline GitHub Actions Workflow
pipeline {
  triggers {
    upstream(
      upstreamProjects: 'job1,job2',
      threshold: hudson.model.Result.SUCCESS
    )
  }
}
jobs:
  job1:
  job2:
    needs: job1
  job3:
    needs: [job1, job2]

Building with multiple operating systems

Jenkins Pipeline GitHub Actions Workflow
pipeline {
  agent none
  stages {
    stage('Run Tests') {
      matrix {
        axes {
          axis {
            name: 'PLATFORM'
            values: 'macos', 'linux'
          }
        }
        agent { label "${PLATFORM}" }
        stages {
          stage('test') {
            tools { nodejs "node-12" }
            steps {
              dir("scripts/myapp") {
                sh(script: "npm install -g bats")
                sh(script: "bats tests")
              }
            }
          }
        }
      }
    }
  }
}
name: demo-workflow
on:
  push:
jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, ubuntu-latest]
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 12
      - run: npm install -g bats
      - run: bats tests
        working-directory: scripts/myapp