I am using Jenkins with Github pull request builder plugin
https://wiki.jenkins.io/display/JENKINS/GitHub+pull+request+builder+plugin
It's fine to trigger the build when the PR is open or update but I need a way to trigger when the PR is closed or merged.
I use Terraform to launch a bunch of servers so I need the event or condition to terminate the stack after the PR is closed/merged.
Seems like most of the plugins only be trigger by open/update event on Github PR.
Any idea?
Thank you!
Follow the steps as mentioned below to trigger a Jenkins job automatically based on GitHub's webhook configurations: Step 1: Go to the Configuration page of the respective job and under the build trigger section, check the "GitHub hook trigger for GITScm polling" checkbox and click on the Save button.
Once the repository maintainer has approved a pull request, the developer's new updates in the forked repository are merged with the main project repository. The product is then updated with the new feature or bug fix, and can now be viewed by end users.
For Jenkins to receive PR events through the pull request plugin, you need to add the Jenkins pull request builder payload URL in the Github repository settings. If you need just the PR triggers, you can select the “Let me select individual events” option and select just the “Pull requests” option.
You can do so by two methods:
1) Either by a webhook. This requires your jenkins to have a public endpoint or some public endpoint (could be a proxy) via which github can post to your jenkins.
https://wiki.jenkins.io/display/JENKINS/GitHub+Plugin#GitHubPlugin-ManualMode
2) If a public endpoint is not available, then poll the repo every minute as a workaround.
http://www.andyfrench.info/2015/03/automatically-triggering-jenkins-build.html
Please note that in bigger setups, poll may have some performance implications. (I have been using it for years without any problems in smaller setups).
https://blogs.microsoft.co.il/leonj/2017/01/24/jenkins-poll-scm-the-nightmare-for-performance/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With