10 June 2018

Integrating Jenkins with GitHub

In this exercise, we are going to integrate Github with Jenkins using webhook that triggers an event
every time you commit a change in your code residing in your GitHub repository to invoke a job in your Jenkins.

To start with, you should be having the following in place.

a. A Github account with a code repository 
b. Jenkins up and running
c. Github plugin for integration with Jenkins

First, we going to create a webhook from our code repository by navigating

GitHub > your-code-repository > settings > webhooks > Add webhook 

add Payload URL - https://jenkinsUrl:8080/github-webhook/
Content type - choose application/json
Secret - you can leave this field blank
Which events would you like to trigger this webhook? - Select - Just the push event
Check the Active box - this will deliver the first payload to test the provided URL
Add webhook

Now come to Jenkins are create a freestyle project by navigating

Jenkins > new Item > item name > Freestyle project > OK

select Github project, and give project URL - https://github.com/punitporwal07/aws-codedeploy-linux/
for Source code management, select git and give repository URL - https://github.com/punitporwal07/aws-codedeploy-linux.git
Keep Branch Specifier as - */master
Under Build Triggers - check GitHub hook trigger for GITScm polling
Save

that's it. Now make a code commit in your git repo, the webhook associated with your repository detects the change and trigger a payload to your Jenkins job which you created in the above step.

you will be able to see the console output of your build as below









--

No comments:

Post a Comment