Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2020-10-23T17:36:13.253Z
Answers: 2020-10-23T17:36:13.253Z
Answers: primetheus
Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2019-10-23T15:21:15.433Z
Answers: 2019-10-23T15:21:15.433Z
Answers: Dima
Body: <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>
  
Comments: CC BY-SA 4.0
Comments: 2019-06-06T16:15:29.403Z
Comments: 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
Comments: primetheus
Comments: CC BY-SA 4.0
Comments: 2019-08-13T09:46:35.637Z
Comments: Have you figured out how to access payload in the build? I'm trying to figure out the same problem.
Comments: finspin
Tags: <jenkins><jenkins-pipeline><github><jenkinsfile>
Title: GitHub Payload in Jenkins
UserDisplayName: primetheus
ThreadText: # GitHub Payload in Jenkins
  
  (Asked by: username_0 on 2019-06-05)
  
  I'm using the [GitHub plugin](https://plugins.jenkins.io/github) 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](https://support.cloudbees.com/hc/en-us/articles/224621648-GitHub-Webhook-Troubleshooting).
  
  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](https://github.com/jenkinsci/github-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github/webhook/GHEventPayload.java#L61-L78), 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>.
  
  
  ---
  
  