Certified Jenkins Engineer
Backup and Configuration Management
Demo Migrating Jenkins Pipeline to GitHub Action
In this tutorial, you'll learn how to migrate existing Jenkins jobs into GitHub Actions workflows using the GitHub Actions Importer.
Prerequisites
- A Jenkins account or organization with pipelines to migrate
- A Jenkins personal API token with read or admin permissions
- Docker installed (required by the importer)
- GitHub CLI (
gh
) installed and authenticated
Limitations
Some features cannot be migrated automatically:
Limitation | Impact |
---|---|
Scripted pipelines | Not supported—only declarative syntax |
Secrets & unknown plugins | Must be recreated or handled manually |
1. Install GitHub CLI & Importer Extension
On Ubuntu, add the GitHub CLI repository and install:
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
&& 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/github/cli/releases/apt/ \
$(lsb_release -cs) main" \
| sudo tee /etc/apt/sources.list.d/github-cli.list \
&& sudo apt update \
&& sudo apt install gh -y
Install the GitHub Actions Importer:
gh extension install github/gh-actions-importer
gh actions-importer -h
2. Authenticate with GitHub
Log in to GitHub via the CLI:
gh auth login
Follow the browser prompts to authorize.
3. Configure Importer Credentials
You need two tokens:
GitHub Personal Access Token (classic)
- Scopes:
repo
,workflow
- Create under Settings → Developer settings → Personal access tokens → Tokens (classic)
- Scopes:
Jenkins API Token
- Go to People → [your user] → Configure → API Token
- Copy it before leaving the page
Run the configuration command and answer prompts:
gh actions-importer configure
- Choose Jenkins
- Enter your GitHub token & base URL (
https://github.com
) - Enter your Jenkins token, username & base URL (e.g.
http://64.227.187.25:8080/
)
4. Update the Importer
Keep the extension up to date:
gh actions-importer update
5. Audit & Forecast (Optional)
Review your Jenkins jobs before migration:
gh actions-importer audit jenkins --output-dir tmp/audit
Estimate GitHub Actions runner usage (requires a Jenkins plugin):
gh actions-importer forecast jenkins
6. Dry Run a Jenkins Job
Locate your full Jenkins job URL:
Execute a dry-run to preview the workflow:
gh actions-importer dry-run jenkins \
--source-url http://64.227.187.25:8080/job/Generate%20ASCII%20Artwork/ \
--output-dir tmp/dry-run
Inspect the generated workflow YAML:
cat tmp/dry-run/Generate_ASCII_Artwork/.github/workflows/generate_ascii_artwork.yml
name: Generate_ASCII_Artwork
on:
workflow_dispatch:
env:
# TimestamperBuildWrapper was not converted
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: run command
shell: bash
run: |
# Fetch a piece of advice
curl -s https://api.adviceslip.com/advice > advice.json
cat advice.json
# Validate word count
jq -r .slip.advice advice.json > advice.message
[ $(wc -w < advice.message) -gt 5 ] \
|| (echo "Advice has 5 words or less" && exit 1)
# Install cowsay and display
sudo apt-get install cowsay -y
export PATH="$PATH:/usr/games:/usr/local/games"
cowsay -f "$(ls /usr/share/cowsay/cows | shuf -n 1)" \
< advice.message
7. Migrate to GitHub Actions
Prepare your target repository (e.g., jenkins-to-actions
):
Run the migration:
gh actions-importer migrate jenkins \
--source-url http://64.227.187.25:8080/job/Generate%20ASCII%20Artwork/ \
--target-url https://github.com/jenkins-kk-demo/jenkins-to-actions \
--output-dir tmp/migrate
A pull request will be created automatically:
Merge the PR to land the workflow in .github/workflows/generate_ascii_artwork.yml
:
cat .github/workflows/generate_ascii_artwork.yml
name: Generate_ASCII_Artwork
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- 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 install cowsay -y
export PATH="$PATH:/usr/games:/usr/local/games"
cowsay -f "$(ls /usr/share/cowsay/cows | shuf -n 1)" \
< advice.message
8. Run the Workflow
Trigger the workflow manually or push to main
:
After completion, check the logs to see your ASCII artwork output.
Links & References
Watch Video
Watch video content