How to integrate Jenkins pipeline with public GitHub project

How to integrate Jenkins pipeline with public GitHub project


  1. Configured master node based on CentOS 7 machine
  2. Configured worker node based on Ubuntu 18.04 machine
  3. Sample parameterized Jenkins job that executes shell script to calculate the sum of two numbers


  1. Sample GitHub project with public access (does not require specifying credentials in Jenkins)
  2. Git installed on worker node (ensure that default Git plugin is enabled in Jenkins)
  3. Personal access token configured on GitHub

Job configuration:

  1. In the Jenkins dashboard create a freestyle project job
  2. In job configuration go to Source Code Management --> Select Git --> Place repository URL of the GitHub project --> Specify the main branch: git
  3. Go to the General tab and select This project is parameterized to add two numbers: parameters
  4. Go to the build step and add a shell script to execute the test script from the GitHub project: shell
  5. Go to the project and press Build with Parameters to specify numbers: number
  6. If everything is correct you should see the successful build: build

Create personal access token on GitHub:

  1. Still, the configured job above is manually triggered, in order to automate the job execution we need to set up the webhook.
  2. In order to set up the webhook in Jenkins we need to have an access token for basic authentication with GitHub
  3. Create personal access token at with repo and admin hook scopes: scope

Configure webhook in Jenkins for GitHub project:

  1. Login into Jenkins dashboard and go to Manage Jenkins --> Configure System --> GitHub Server:
  2. Add GitHub access token with Secret Text kind: secret
  3. Press the Test connection button to check the connectivity with GitHub and select Manage hooks: github
  4. Save the changes
  5. Go back to your job configuration dashboard and in Build Triggers tab select GitHub hook trigger for GitScm polling: hook
  6. In the webhooks section of the GitHub repository you will find the new added webhook: webhook
  7. Clone the repository and try to test the build by pushing changes to the remote repository: commit

Troubleshooting tips:

  1. Check if the worker node is up and running
  2. Check if your builds in Jenkins run on the worker node by default and not the master node
  3. Check if the default Git plugin is installed and enabled
  4. Check if you specified the correct branch (e.g. main)
  5. Check if git is installed on the worker node


  1. Jenkins and github integration
  2. GitHub Webhook Integration