1

I'm using the GitHub plugin with Jenkins, and I'm trying to figure out how I can access the webhook payload. I'm aware that the Generic Webhook Trigger has this ability, as well as the GitHub Pull Request plugin, but this plugin seems more suitable to an automated workflow.

On that note, what I'm looking at is importing the class and parsing the payload, similar to what is done in the troubleshooting section here.

This sample works, but only prints the class:

import org.kohsuke.stapler.StaplerRequest
import org.jenkinsci.plugins.github.webhook.GHEventPayload
import org.jenkinsci.plugins.github.webhook.GHEventPayload.PayloadHandler

payload = new PayloadHandler()
println(payload)

This sample wants more info, but I'm not handy enough with Java to know what it's asking for:

import org.kohsuke.stapler.StaplerRequest
import org.jenkinsci.plugins.github.webhook.GHEventPayload
import org.jenkinsci.plugins.github.webhook.GHEventPayload.PayloadHandler

payload = new PayloadHandler()
println(payload.parse())

According to the source code, that's the method I need, but it produces the following error:

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: org.jenkinsci.plugins.github.webhook.GHEventPayload$PayloadHandler.parse() is applicable for argument types: (java.lang.Class) values: [interface org.jenkinsci.plugins.github.webhook.GHEventPayload]
Possible solutions: parse(org.kohsuke.stapler.StaplerRequest, java.lang.annotation.Annotation, java.lang.Class, java.lang.String), parse(org.kohsuke.stapler.StaplerRequest, org.jenkinsci.plugins.github.webhook.GHEventPayload, java.lang.Class, java.lang.String), use([Ljava.lang.Object;), use(java.lang.Class, groovy.lang.Closure), wait(), grep()

Has anyone tried something like this before?

  • Seems this is a Utility Class... I'm fairly new to the concept of utility classes, but I'll post an answer if I figure it out – primetheus Jun 6 '19 at 16:15
  • Have you figured out how to access payload in the build? I'm trying to figure out the same problem. – finspin Aug 13 '19 at 9:46
1

GitHub plugin doesn't pass payload data to any variables available from inside the pipeline.

Both Jenkins tracker and GitHub plugin project have a number of open and cancelled feature requests requesting this, for instance, https://issues.jenkins-ci.org/browse/JENKINS-24291.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.