Steps to configure PR jobs on Jenkins This job will run every time someone creates a pull request on your Github repository
- On Jenkins
- Install Jenkins PR Plugin https://plugins.jenkins.io/ghprb/
- Create a freestyle project
- Add Github project link
- In Source code management > branch specifier add
${ghprbActualCommit}
- Click on advance and add Refspec as "+refs/pull/:refs/remotes/origin/pr/" (because we want to run only for PRs)
- In Triggers, select "Github Pull Request Builder"
- Check "Use github hooks for build triggering"
- Check "Build every pull request automatically without asking (Dangerous!)."
- Whitelist target branch, in our case i.e. develop
- In build step, add execute shell and write your code which is supposed to be executed. Like running test, posting results etc.
- Click on "Apply" and then "Save"
- Configurations on GitHub site
-
Goto repository > settings > Hooks
-
Click on "Add webhook"
-
In URL type
<Jenkins Server URL\>/ghprbhook/
If you get this error,
HTTP ERROR 403 No valid crumb was included in the request
You probably forget the slash at the end)
-
Selct Content Type as "application/json"
-
Under "Which events would you like to trigger this webhook?", select "Let me select individual events."
-
Select "Pushes" and "Pull requests" from available options Select checkbox in front of "Active" Click on "Create Webhook"
-