generic-webhook-trigger-plugin | HTTP request , extract any values from JSON or XML | Plugin library
kandi X-RAY | generic-webhook-trigger-plugin Summary
kandi X-RAY | generic-webhook-trigger-plugin Summary
This is a Jenkins plugin that can:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Build the environment for the given run
- Checks if the run is not logged in
- Gets the post content
- Returns the resolved variables
- Whether the variables should be printed
- Is print post content
- Command line tool
- Downloads a file from an URL
- Checks if the provided credentials id is valid
- Finds the credential with the given credentials id
- Checks to see if the request should be processed
- Fill a list box with the credentials id items
- Registers this form
generic-webhook-trigger-plugin Key Features
generic-webhook-trigger-plugin Examples and Code Snippets
Community Discussions
Trending Discussions on generic-webhook-trigger-plugin
QUESTION
This should be an easy, out-of-the-box configuration in Jenkins but I haven't found anything straightforward on the internet. All I want to do is a trigger a build ONLY when a pull request i merged in our Github repo.
To start with, Github aggregates almost all activity around the pull request into one webhook (versus bitbucket which allows you to differentiate between actions).
On the Jenkins side I've seen posts point towards the Generic Webhook Plugin which allows you to ingest the json of the webhook and create variables, however from here it looks like those need to be used in a script in order to trigger/not trigger a build.
Github Pull Request Build is another popular plugin, but again there is nothing explicit that states "only trigger this build when a PR is merged" or even seems to give the option of looking for a specific value in the webhook json.
Unless there are other plugins out there I haven't found the best option (i.e. least configuration to just get the build started) is to configure the GitHub hook trigger for GITSCM polling in Jenkins and on the Github side send the webhook only on push events... however this isn't the exact behavior we're looking for.
Right now this is all being done via the UI, and it's been awhile since I've used Jenkins so maybe the declarative pipeline infrastructure has passed the UI by, but it seems like this should be much more intuitive. Can someone explain the easiest implementation they've found, using Jenkins and Github, to trigger a build ONLY when a pull request is merged to a specific branch?
...ANSWER
Answered 2020-Sep-24 at 21:08you can configure the generic webhook trigger plugin to parse the payload json coming from the github.
first make sure that you have checked Pull requests in github webhook configuration
now you can look up for the merged key in webhook json, more details given at this url: https://developer.github.com/webhooks/event-payloads/#pull_request
first you need to check for the action key if it is closed then check for the merged key. according to the official documentation If the action is closed and the merged key is false, the pull request was closed with unmerged commits. If the action is closed and the merged key is true, the pull request was merged.
now configure the generic webhook to read they action and merged key from the payload in your jenkins pipline you can follow this example: https://github.com/jenkinsci/generic-webhook-trigger-plugin/blob/master/sandbox/multibranch.jenkinsfile
in your pipeline you can use these keys to check if you want to trigger the build or not.
for triggering the build on merge on a specific branch you can use environment variables in jenkins pipeline the env.BRANCH_NAME
will tell you what branch you got the commit from
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install generic-webhook-trigger-plugin
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page