Jenkins GitHub Integration | How to Do It | Blazemeter by Perforce
jenkins and github are two powerful tools on their own, but what about using them together? In this blog, learn about the benefits of a Jenkins GitHub integration and how to set up the integration on your own.
- can you use jenkins with github?
- why integrate github + jenkins?
- how to configure jenkins + github integration
can you use jenkins with github?
You can and should use jenkins with github to save time and keep your project up to date.
one of the basic steps to implement ci/cd is to integrate your scm (source control management) tool with your ci tool. this saves you time and keeps your project up to date all the time. one of the most popular and valuable scm tools is github.
what is github?
github is a git-based repository host, commonly used for open source projects. github allows for code collaboration, hosting, and version control.
what is jenkins?
jenkins is an open source continuous integration and continuous deployment (ci/cd) tool for automating the software development lifecycle (sdlc). With Jenkins Testing, teams can automate code building, testing, and deployment.
why integrate github + jenkins?
You should integrate jenkins and github to improve the efficiency of building, testing, and deploying your code.
The integration presented in this blog post will teach you how to schedule your build, pull your code and data files from your github repository to your jenkins machine, and automatically trigger each build on the jenkins server after each commit on your jenkins machine. git repository.
But first, let’s set up the jenkins and github integration. let’s start with the github side!
how to configure jenkins + github integration
step 1: go to your github repository and click ‘settings’.
Step 2: Click webhooks and then click ‘add webhook’.
Step 3: In the ‘payload url’ field, paste the url of your jenkins environment. at the end of this url add /github-webhook/. in the ‘content type’ select: ‘application/json’ and leave the ‘secret’ field empty.
Step 4: On the ‘which events would you like to trigger this webhook?’ page choose ‘let me select individual events’ and then check ‘pull requests’ ‘ and ‘push’. at the end of this option, make sure the ‘active’ option is checked and click ‘add webhook’.
We are done with the configuration on the github side! now let’s move on to jenkins.
step 5: in jenkins, click ‘new item’ to create a new project.
step 6: give your project a name, then choose ‘freestyle project’, and finally click ‘ok’.
Step 7: Click on the ‘source code management’ tab.
Step 8: Click on git and paste the url of your github repository into the ‘repository url’ field.
Step 9: Click on the ‘build triggers’ tab and then on the ‘gitscm polling github link trigger’. or choose the trigger of your choice.
that’s it! your github repository is integrated with your jenkins project. With this jenkins github integration, you can now use any file found in the github repository and trigger the jenkins job to run on every code commit.
For example, I’ll show you how to run a taurus script that I uploaded to my github repository from my jenkins project. taurus is an open source load testing solution that allows developers to run load test scripts from sophisticated platforms like jmeter and selenium, but with simple yaml code.
trigger jenkins github integration with every code commit
step 10: click the ‘build’ tab, then click ‘add build step’ and choose ‘run shell’.
Step 11: To run a taurus test, simply use the command ‘bzt’, followed by the name of your yml file, and click ‘save ‘.
step 12: go back to your github repository, edit the taurus script and commit the changes. now we will see how jenkins executed the script after commit.
step 13: go back to your jenkins project and you will see that a new job was automatically activated from the commit we made in the previous step. click the little arrow next to the job and choose ‘console output’.
step 14: you can see that jenkins was able to extract the taurus script and run it.
congratulations! you have now set up a fully working jenkins github integration. every time you push 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 will have completed a crucial step towards the full ci process. now, you can move on to the testing phase. To complete the full CI process, integrate your load test into your CI tool. using blazemeter’s integration with jenkins, incorporating load testing into your ci/cd pipeline has never been simpler.
start testing now