Sunday, October 6, 2013

Integrate Jenkins and GitHub to trigger build process on code commit

In this post we can explore how to integrate GitHub repository with jenkins CI server. 
This blogpost talks about installing GitHub plugin on jenkins server, configuring GitHub repository on jenkins and creating service hooks on GitHub which will trigger build process as soon as someone’s commit new code to GitHub repository.
INSTALL and CONFIGURE GITHUB PLUGIN ON JENKINS
To install GitHub plugin, navigate to your Jenkins Dashboard, click on “Manage Jenkins” and select “Manage Plugins”.
image
On the plugins page, select “Available” tab and search for “GitHub plugin” under “External Site/Tool Integrations”.
image
Install the plugin. This will restart Jenkins server.
image

Once done, navigate back to dashboard for “Manage Jenkins” and select “Configure System”. Under that, you might observe that Git is not installed.
image
If so, login into your EC2 instance and issue command :
# yum install git
image
Once done, please go further down the page and provide your username and email details for GitHub account.
image
That’s it !! We have installed and configured our GitHub plugin on jenkins.
CREATE JENKINS JOB AND CONFIGURE GITHUB REPOSITORY
After installing GitHub plugin, it is time to create Jenkins job and integrate GitHub repository to it.
On Jenkins dashboard, click on “New Job” and provide name to “Build a free style software project” job.
image
Provide the path of GitHub repository under “GitHub Project” and provide “repository URL” for “GIT” under “Source Code Management”.
image
Lower down the page, don’t forget to enable “Build when a change is pushed to GitHub”.
image
Now, we have configured Jenkins job in such a way that whenever a change is committed to GitHub repository - this will trigger build process on Jenkins.
CONFIGURE GITHUB SERVICE HOOK
To trigger the build process on Jenkins, we need to configure service hook on GitHub. In order to achieve this, navigate to GitHub repository settings and configure Jenkins Hook URL for GitHub plugin.
The URL format : http://<jenkins-username>:<jenkins-password>@<Elastic-IP-Address>:8080/github-webhook/
image
That’s it !! GitHub is now integrated with Jenkins. If any developer commits any code to GitHub repository, this will trigger the build process on Jenkins.

No comments:

Need Consulting help ?

Name

Email *

Message *

DISCLAIMER
All posts, comments, views expressed in this blog are my own and does not represent the positions or views of my past, present or future employers. The intention of this blog is to share my experience and views. Content is subject to change without any notice. While I would do my best to quote the original author or copyright owners wherever I reference them, if you find any of the content / images violating copyright, please let me know and I will act upon it immediately. Lastly, I encourage you to share the content of this blog in general with other online communities for non-commercial and educational purposes.

Followers