Jenkins Plugins for PR events
You can use Generic Webhook Trigger plugin for triggering Jenkins builds on PR events and get the pr number from the payload it sends to trigger test runs from HyperTest CLI.
To achieve it, you will have to do the following
Send webooks to Jenkins webhooks trigger on pull request events from your codebase
Install Generic Webhook Plugin in Jenkins
Configure Plugin in your pipeline
Steps:
1. Send Webhooks to Jenkins
Go to Webhooks
Add a new Webhook
Payload Url: Wehook trigger listens on /generic-webhook-trigger/invoke.
If you have any authentication on jenkins, pass it in webhook url like below http://<username>:<password>:@<jenkins_ip>:<jenkins_port>/generic-webhook-trigger/invoke
Content type: application/json
Add any secret if required
To trigger the webhooks on pull request events only, select let me select individual events and check pull requests
Save and add Webhook
2. Install Plugin in Jenkins
Install Generic Webhook Plugin from Jenkins plugins page and restart Jenkins after the plugin is installed
3. Configure Plugin in pipeline to pick PR number
Go to configure tab in your pipeline
Check the Generic Webhook plugin option under Build triggers
To fetch the pull request id, add the parameter in post content parameter Variable Name: pull_request_number Expression: $.pull_request.number
Add other envs/token or other settings if required and save
Now you access the parameter by $pull_request_number
Export HT_PR parameter inside your Jenkinsfile
export HT_PR=$pull_request_number
Sample files for CI/CD with Generic Trigger
Alternatively you can also control environment variables of Generic Webhook plugin from your Jenkinsfile like below, and add it in HT_PR in environment section
Jenkins Plugins for PR events
2. Install Plugin in Jenkins
Install Generic Webhook Plugin from Jenkins plugins page and restart jenkins after the plugin is installed
3. Configure Plugin in pipeline to pick PR number
1.Go to configure tab in your pipeline
2.Check the generic webhook plugin option under Build triggers
3.To fetch the pull request id, add the parameter in post content parameter Variable Name: pull_request_number Expression: $.pull_request.number
4.Add other envs/token or other settings if required and save
5.Now you access the parameter by $pull_request_number
6.Export HT_PR parameter inside your Jenkinsfile
export HT_PR=$pull_request_number
Sample files for CI/CD with Generic Trigger
Alternatively you can also control environment variables of Generic Webhook plugin from your Jenkinsfile like below, and add it in HT_PR in environment section
Last updated