Advanced Jenkins
Backup and Configuration Management
Migrating Jenkins Pipeline to GitHub Action
Learn how to seamlessly migrate your existing Jenkins jobs into GitHub Actions workflows using the GitHub Actions Importer CLI extension. This guide walks you through installation, configuration, and execution, so you can automate CI/CD with GitHub’s native tooling.
Table of Contents
- Prerequisites
- Install GitHub CLI & Importer
- Authenticate GitHub CLI
- Generate and Configure Tokens
- Configure the Importer
- Update the Importer
- Dry-Run a Pipeline Migration
- Migrate to GitHub Actions
- Verify the Workflow
- Conclusion & References
Prerequisites
Before starting the migration, ensure you have the following resources in place:
Resource | Purpose |
---|---|
Jenkins account or organization | Source of pipelines/jobs to migrate |
Jenkins personal API token | Grants API access to read pipeline definitions |
Docker | Required to run the Importer CLI in a container (optional) |
GitHub CLI (gh ) v2+ | Manages GitHub authentication and extensions |
GitHub Personal Access Token | Requires the workflow scope for creating workflows |
Warning
The importer cannot migrate scripted pipelines, secrets, or unknown plugins. Make sure your Jenkins jobs use declarative pipelines or simple freestyle jobs.
Install GitHub CLI & Importer
On Debian/Ubuntu
# 1. Install prerequisites
type -p wget >/dev/null || sudo apt update && sudo apt-get install -y wget
# 2. Add GitHub CLI apt repository
sudo mkdir -p /etc/apt/keyrings
wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg \
| sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg
sudo chmod 644 /etc/apt/keyrings/githubcli-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) \
signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] \
https://cli.github.com/repos/cli/cli/releases stable main" \
| sudo tee /etc/apt/sources.list.d/github-cli.list >/dev/null
sudo apt update && sudo apt install -y gh
Add the Actions Importer Extension
gh extension install github/gh-actions-importer
Verify the installation:
gh actions-importer --help
Authenticate GitHub CLI
Login interactively to GitHub:
gh auth login
Follow the browser prompts to complete authentication.
Generate and Configure Tokens
1. GitHub Personal Access Token (Classic)
- Navigate to Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click Generate new token, name it (e.g.
jenkins-importer
), and select theworkflow
scope - Copy the token for later use
2. Jenkins API Token
- Sign in to Jenkins and go to Manage Jenkins → Users
- Select your user and click Configure
- Under API Token, select Add new Token, name it (e.g.
GitHub Importer
), then generate and copy it
Configure the Importer
Run the configuration command:
gh actions-importer configure
When prompted, enter:
- GitHub Personal Access Token
- GitHub Base URL:
https://github.com
- Jenkins Personal Access Token
- Jenkins Username
- Jenkins Base URL (e.g.
http://your.jenkins.server:8080
)
Successful output:
Environment variables successfully updated.
Update the Importer
Keep your extension up-to-date:
gh actions-importer update
Example output:
ghcr.io/actions-importer/cli:latest up-to-date
Dry-Run a Pipeline Migration
Preview the generated workflow YAML locally without pushing changes:
gh actions-importer dry-run jenkins \
--source-url http://your.jenkins.server:8080/job/Generate%20ASCII%20Artwork/ \
--output-dir tmp/dry-run
On success, inspect the file:
tmp/dry-run/Generate_ASCII_Artwork/.github/workflows/generate_ascii_artwork.yml
# tmp/dry-run/Generate_ASCII_Artwork/.github/workflows/generate_ascii_artwork.yml
name: Generate_ASCII_Artwork
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run command
shell: bash
run: |
curl -s https://api.adviceslip.com/advice > advice.json
jq -r .slip.advice advice.json > advice.message
[[ $(wc -w < advice.message) -gt 5 ]] || { echo "Advice has 5 words or less"; exit 1; }
sudo apt-get update && sudo apt-get install -y cowsay
export PATH="$PATH:/usr/games:/usr/local/games"
cowsay -f "$(ls /usr/share/cowsay/cows | shuf -n1)" "$(cat advice.message)"
Migrate to GitHub Actions
Generate a pull request with the new workflow files:
gh actions-importer migrate jenkins \
--source-url http://your.jenkins.server:8080/job/Generate%20ASCII%20Artwork/ \
--target-url https://github.com/<owner>/jenkins-to-actions \
--output-dir tmp/migrate
This command creates a PR in the target repository for review and merge.
Merge the PR to apply the workflow to the main
branch.
Verify the Workflow
After merging, trigger the workflow manually or via push. Monitor runs in the Actions tab:
Conclusion & References
The GitHub Actions Importer CLI accelerates the transition from Jenkins to GitHub’s CI/CD platform. For full details, visit the official documentation.
Note
Enjoy seamless pipeline migration and take advantage of GitHub Actions for robust workflow automation.
Links and References
Watch Video
Watch video content