Trigger a Jenkins Build on Every Code Push Event
Configure GitHub project
Go to your GitHub repository settings and click on Webhooks. Click on add a webhook.
In payload URL, add your jenkins installation URL + ‘/github-webhook/’. For example if my jenkins is running at https://jenkins.example.com:8080, I’ll add https://jenkins.example.com:8080/github-webhook/. Disable SSL verification. Select send me everything or you can select only push events. and lastly check the box which says Active.
Configure Jenkins project
Go to your jenkins project configuration. Let’s say I have a project ak-project, I’ll go to https://jenkins.example.com:8080/job/ak-project/configure.
Go to Build Triggers tab.
Check the option which says, GitHub hook trigger for GITScm polling.
Save your changes.
You’re all done. Now push some code to GitHub repository and see the magic in Jenkins… Enjoy!