How to Integrate Jenkins with GitHub?
How do I trigger a build automatically in Jenkins?
1. Click on New item
2. Enter a project name
3. Click on OK
4. Go to ‘Source Code Management’

5. Go to ‘Build Trigger’
a. Select ‘GitHub hook trigger for GITScm polling’
Because job will listen from Git hub webhooks

6. Now go to Git repository
a. Click on Settings

b. Go to Webhooks
c. Click on ‘Add webhook’



6. Now go to Git repository
a. Click on Settings

b. Go to Webhooks
c. Click on ‘Add webhook’


d. Now you need to enter Payload URL and that url should be your ‘Jenkins url’ followed by ‘/github-webhook/’
So it will look like this ‘http://192.168.0.103:8080/github-webhook/’
e. Select ‘Content Type’ as ‘application/json’
f. Click on Add button

Webhook added successfully

Now whenever you push the changes to your Git repository then Jenkins will trigger the build and it will start execution.
So it will look like this ‘http://192.168.0.103:8080/github-webhook/’
e. Select ‘Content Type’ as ‘application/json’
f. Click on Add button

Webhook added successfully

Now whenever you push the changes to your Git repository then Jenkins will trigger the build and it will start execution.
Note: If Jenkins build is not triggering that's mean the connection is not being established git webhooks to Jenkins
1. install ngrok: https://ngrok.com/download
which expose localhost urls over internet.
2.After installation of the ngrok run it e.g./ngrok http 8080
It will give you a url like this: http://3b2db437.ngrok.io
Now under payloadUrl: type the url as:http://3b2db437.ngrok.io:8080/github-webhook/
Now the localhost Jenkins setup would run and the payload error would be gone.
Note: In above URL, you mentioned 8080 again. Since the url generated on ngrok already contains this, adding it again would result in service timeout error : "We couldn’t deliver this payload: Service Timeout".
It will give you a url like this: http://3b2db437.ngrok.io
Now under payloadUrl: type the url as:http://3b2db437.ngrok.io:8080/github-webhook/
Now the localhost Jenkins setup would run and the payload error would be gone.
Note: In above URL, you mentioned 8080 again. Since the url generated on ngrok already contains this, adding it again would result in service timeout error : "We couldn’t deliver this payload: Service Timeout".
No comments:
Post a Comment