In this article we
will see how we can configure Jenkins with Github. Our goal is to make Jenkins
pull code from the Github repository and build that code locally.
1) The basic steps
are to configure the Github with a repository and push some code. Use the
articles from the Git.
2) Once the code is
pushed to the Github, we need to then make configuration changes on the Jenkins
side so that jenkins can pull the code from the Github repository and build the
code locally
3) Git hub provides
some thing called as the hooks which allows the communication. The post-receive
hook of Github are actually only "WebHooks", to communicate with a
web server whenever the repository is pushed to.
1) Click on the
Settings of the repository in Github. Then go to the Webhooks and Services.
2) In the service , search
for Jenkins for Github service and choose
Now once you choose
the service ,you need to enter the locally run jenkins details in the jenkins
hook url as above.
Make sure you get
you IP address ( using ifconfig command in linux) and configure the URL as
http://<IP
address>:<Port>/github-webhook/
the next step is
click on the "Test Service" which will return a payload. If the payload
was success, then the configuration test is fine.
2) Configurations
need to be done on Jenkins. Once the Configuration on the Github side is done,
we need to make some configuration changes on the Jenkins side to connect to
the Github and get the source code for building
Choose a New Item
from Jenkins for building the Code. Go for the project type if that is maven
and click Ok . in the next screen configure the GitHub repository details as
shown in the screen shot,
Provide the Github
repository details in the Github project URL for the Build Item. Also provide
the Github credentials if needed to connect.
In the below part of the same screen , choose the
"Poll SCM" check box and add " H/5 * * * *" which will poll
the source code for every 5 minutes and build the code.
Jenkins does
provide a options to build when a Push to the Github from the local Git is done
but Since your jenkins is not accessible from a public IP address, GitHub can
not trigger the build via WebHook
So we use the Poll
mechanism to poll code for every 5 minutes from Github and build the code. Once
the Poll is done we see some thing like this
More to Come,Happy Learning
Thanks to my father who shared with me concerning this blog, this blog is in fact remarkable.
ReplyDeleteMy webpage line let's get rich hack
Hi sir,
ReplyDeleteI have read some of your posts in your blog,is excellent.
But i need more explanation on some topics and your help to learn open shift and Git.
Please reply me your interest.
Thanking you advance :)