Auto Trigger Jenkins Build /Jobs with github webhook
We're going to do github integration with jenkins using github webhook.
Last updated
We're going to do github integration with jenkins using github webhook.
Last updated
You should have jenkins server hosted on public IP accessible remotely.
If you have localhost, you can also port your ip with any public IP. Ngrok is also a another option you can try.
To set webhook on the repo. Follow the path as given :
In my case, https://github.com/whoami-anoint/Hitop/settings/hooks/
Payload URL : http://103.60.176.158:8080/github-webhook/
Content type: application/json
Secret : blank
Which events would you like to trigger this webhook?
Then make webhook active.
Make sure the payload url should end with /. (To fix: 302 error)
Content type be application/json . ( To fix : 502 error)
Make sure you are getting 200 response.
Webhook is finally added on github repo.
Now, time to make pipeline on jenkins with the github repo:
Add new item -> Pipeline
Give any pipeline name. (Repo name is preferred to reference.)
Source Code Management -> Repository URL and credentials (if private repo)
Branches to build -> */main (your branch)
Make any changes on github repo.
Let's check on jenkins:
Also check on jenkins console:
Started by GitHub push by whoami-anoint
Build Triggers -> GitHub hook trigger for GITScm polling
We have successfully auto triggered the jenkins build using github webhook. Whenever, we made any changes on our github repo, that will be auto merge and auto build in jenkins.