Guy Salton is a technical expert on the whole performance testing ecosystem - load testing tools, monitoring tools, CI tools, Networking and Infrastructure. His expertise is helping with POCs and special technical projects for strategic customers. Guy talks at conferences and meetups around the world, writes blog posts and gives webinars.

Learn JMeter in 5 Hours

Start Learning
Slack

Run massively scalable performance tests on web, mobile, and APIs

Dec 11 2018

How to Integrate Your GitHub Repository to Your Jenkins Project

One of the basic steps of implementing CI/CD is integrating your SCM (Source Control Management) tool with your CI tool. This saves you time and keeps your project updated all the time. One of the most popular and valuable SCM tools is GitHub. In this blog we will explain how to integrate Jenkins with GitHub projects.

 

The integration presented in this blog post will teach you to:

  • Schedule your build
  • Pull your code and data files from your GitHub repository to your Jenkins machine
  • Automatically trigger each build on the Jenkins server, after each Commit on your Git repository

 

But first, let’s configure the GitHUb and Jenkins integration. Let's begin with the GitHub side!

 

Configuring GitHub

 

Step 1: go to your GitHub repository and click on ‘Settings’.

 

integrating jenkins and github

 

Step 2: Click on Webhooks and then click on ‘Add webhook’.

 

add github to your ci

 

Step 3: in the ‘Payload URL’ field, paste your Jenkins environment URL. At the end of this URL add /github-webhook/. In the ‘Content type’ select ‘application/json’ and leave the ‘Secret’ field empty.

 

jenkins and gihutb integration tutorial

 

Step 4: in the ‘Which events would you like to trigger this webhook?’ choose ‘Let me select individual events.’ Then, check ‘Pull Requests’ and ‘Pushes’. At the end of this option, make sure that ‘Active’ is checked and click on ‘Add webhook’.

 

jenkins and github integration guide

 

configure github for CI integration

 

We're done with the configuration on GitHub’s side! Now let's move on to Jenkins.

 

Configuring Jenkins

 

Step 5: In Jenkins, click on ‘New Item’ to create a new project.

 

jenkins configuration for github

 

Step 6: Give your project a name, them choose ‘Freestyle project’ and finally click on ‘OK’.

 

jenkins ci, github scm

 

Step 7: Click on the ‘Source Code Management’ tab.

 

adding your scm to continuous integration

 

Step 8: Click on Git and paste your GitHub repository URL in the ‘Repository URL’ field.

 

GitHub and Jenkins combination

 

Step 9: Click on the ‘Build Triggers’ tab and then on the ‘GitHub hook trigger for GITScm polling’. Or, choose the trigger of your choice.

 

triggering builds in jenkins

 

That's it! Your GitHub repository is integrated with your Jenkins project. You can now use any of the files found in the GitHub repository and trigger the Jenkins job to run with every code commit.

 

For example, I will show you how to run a Taurus script that I uploaded to my GitHub repository from my Jenkins project.

 

Triggering the Jenkins Job to Run with Every Code Commit

 

Step 10: Click on the ‘Build’ tab, then click on ‘Add build step’ and choose ‘Execute shell’.

 

code commit, jenkins

 

Step 11: To run a Taurus test, simply use the ‘bzt’ command, followed by the name of your YML file and click on ‘Save’.

 

run taurus in jenkins

 

Step 12: Go back to your GitHub repository, edit the Taurus script and commit the changes. We will now see how Jenkins ran the script after the commit.

 

run jenkins script after commit

 

Step 13: Go back to your Jenkins project and you'll see that a new job was triggered automatically from the commit we made at the previous step. Click on the little arrow next to the job and choose ‘Console Output’.

 

jenkins project with github

 

Step 14: You can see that Jenkins was able to pull the Taurus script and run it!

 

pull a script from github and run it

 

Congratulations! Every time you publish your changes to Github, GitHub will trigger your new Jenkins job.

 

Once the GitHub plugin is fully installed and integrated into your Jenkins project, you have completed a very crucial step towards the full CI process. Now, you can proceed to the testing phase. To complete the full CI process, integrate your load testing into your CI tool. For more details about how to do this with Taurus, an open source automation tool, see here.

Interested in writing for our Blog?Send us a pitch!

Your email is required to complete the test. If you proceed, your test will be aborted.