2
votes

Trying to parse the Github webhook payload(specifically need tag_name from release) in jenkins and make the values available in the build job. Tried using Generic Webhook Trigger plugin as mentioned in the link below How to process a github webhook payload in Jenkins? but without success. Can someone provide an example how to use this plugin and get the tag_name value in Jenkins job ?

2

2 Answers

2
votes

I think this post should help https://bjurr.com/continuous-integration-with-gitlab-and-jenkins/

In short, you will need to create a webhook in GH and a Jenkins Pipeline. Here is an example https://github.com/jenkinsci/generic-webhook-trigger-plugin/blob/master/sandbox/multibranch.jenkinsfile

or using Jenkins Job DSL. (See github.com/jenkinsci/generic-webhook-trigger-plugin)

Hope this helps :D

0
votes

You may add a variable named ref and expression $.ref

Then you can have a filter with text $ref and regexp ^(refs/tags/.+)$

Now the job will only trigger when a tag is pushed.

There is a test case on this in the repo: https://github.com/jenkinsci/generic-webhook-trigger-plugin/blob/master/src/test/resources/org/jenkinsci/plugins/gwt/bdd/github/github-push-tag.feature