<p>What I wanted to do is solvable with <a href="https://github.com/jenkinsci/pipeline-github-plugin" rel="nofollow noreferrer">https://github.com/jenkinsci/pipeline-github-plugin</a></p>

CC BY-SA 4.0
2020-10-23T17:36:13.253Z
2020-10-23T17:36:13.253Z
primetheus
<p>GitHub plugin doesn't pass payload data to any variables available from inside the pipeline.</p>

<p>Both Jenkins tracker and GitHub plugin project have a number of open and cancelled feature requests requesting this, for instance, <a href="https://issues.jenkins-ci.org/browse/JENKINS-24291" rel="nofollow noreferrer">https://issues.jenkins-ci.org/browse/JENKINS-24291</a>.</p>

CC BY-SA 4.0
2019-10-23T15:21:15.433Z
2019-10-23T15:21:15.433Z
Dima
<p>I'm using the <a href="https://plugins.jenkins.io/github" rel="nofollow noreferrer">GitHub plugin</a> 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.</p>

<p>On that note, what I'm looking at is importing the class and parsing the payload, similar to what is done in the <a href="https://support.cloudbees.com/hc/en-us/articles/224621648-GitHub-Webhook-Troubleshooting" rel="nofollow noreferrer">troubleshooting section here</a>.</p>

<p>This sample works, but only prints the class:</p>

<pre><code>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)
</code></pre>

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

<pre><code>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())
</code></pre>

<p><a href="https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github/webhook/GHEventPayload.java#L61-L78" rel="nofollow noreferrer">According to the source code</a>, that's the method I need, but it produces the following error:</p>

<pre><code>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()
</code></pre>

<p>Has anyone tried something like this before?</p>

CC BY-SA 4.0
2019-06-06T16:15:29.403Z
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
CC BY-SA 4.0
2019-08-13T09:46:35.637Z
Have you figured out how to access payload in the build? I'm trying to figure out the same problem.
finspin
<jenkins><jenkins-pipeline><github><jenkinsfile>
GitHub Payload in Jenkins
primetheus
# GitHub Payload in Jenkins

(Asked by: username_0 on 2019-06-05)

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?

**Tags:** jenkins, jenkins-pipeline, github, jenkinsfile

> **Comments:**
> **username_0**: 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  
> **username_1**: Have you figured out how to access payload in the build? I'm trying to figure out the same problem.  

---

## 2 answers

### Answer by username_0 on 2020-10-23. Score: 0 | Accepted answer

What I wanted to do is solvable with <https://github.com/jenkinsci/pipeline-github-plugin>


---

### Answer by username_2 on 2019-10-23. Score: 2

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>.


---

