title: How to configure Jenkins GitHubPullRequestBuilder plugin using Job DSL
body: <p>I am setting up webhook integration between a private GitHub repository and a Jenkins build. I configure jobs exclusively using Job DSL groovy scripts (I'm open to switching to another programmatic job configuration mechanism, but I will not accept any answer that requires me to configure jobs manually). II would like to set up a commit status context and a set of custom messages based on build status.</p>
  <p>The <a href="https://your-jenkins-host.com/plugin/job-dsl/api-viewer/index.html#method/javaposse.jobdsl.dsl.helpers.triggers.TriggerContext.githubPullRequest" rel="noreferrer">Job DSL API documentation embedded in Jenkins</a> is not helpful, only giving me this signature: <code>githubPullRequest(Closure closure)</code>, but not telling me how to construct a suitable closure.</p>
  <p>Here are the relevant sections of my job DSL:</p>
  <pre><code>triggers {
      githubPush()
      githubPullRequest {
          useGitHubHooks()
          buildStatus {
              completedStatus('SUCCESS', 'Build succeeded!')
              completedStatus('FAILURE', 'Build failed. ')
              completedStatus('ERROR', 'Build errored. This is probably a problem with Jenkins or related infrastructure and not an issue with your code changes.')
          }
      }
  }
  
  (...)
  
  scm {
      git {
          remote {
              github('privateorg/myrepo', 'ssh')
              credentials('my-credential-id')
              refspec('+refs/pull/*:refs/remotes/origin/pr/*')
          }
          branch('${sha1}')
      }
  }
  </code></pre>
  <p>This errors as follows:</p>
  <pre><code>ERROR: (build.groovy, line 8) No signature of method: javaposse.jobdsl.dsl.helpers.triggers.TriggerContext.buildStatus() is applicable for argument types: 
  (build$_run_closure1$_closure2$_closure10$_closure11) values: 
  [build$_run_closure1$_closure2$_closure10$_closure11@602572cb]
  </code></pre>
  <p>Line 8 is:</p>
  <pre><code>buildStatus {
  </code></pre>
  <p>If I remove the entire <code>buildStatus</code> block, then Jenkins accepts the script and creates the job successfully. My push hooks work, but my pull request hooks don't.</p>
  <p>I'm not a Groovy programmer, nor am I deeply familiar with any aspect of Jenkins. I understand that there is no method compatible with the DSL I've written, but I don't know where to look to find valid method signatures. I don't understand how the DSL maps to method calls well enough to find or even recognize an appropriate method and build DSL that is compatible.</p>
  <p>Googling the error message led me to some people who had similar problems in 2016-2017: <a href="https://issues.jenkins-ci.org/browse/JENKINS-37647" rel="noreferrer">1</a>, <a href="https://issues.jenkins-ci.org/browse/JENKINS-40181" rel="noreferrer">2</a>, <a href="https://stackoverflow.com/questions/36505926/job-dsl-core-jar-version-updated-to-1-44-githubpullrequest-closure-is-not-work">3</a>. Their issue seemed to stem from the deprecation of the <a href="https://plugins.jenkins.io/ghprb/" rel="noreferrer">Github Pull Request Builder plugin</a> as a core, bundled plugin, and a corresponding change in syntax. That led me to discover a new syntax, given <a href="https://github.com/jenkinsci/ghprb-plugin/blob/master/README.md" rel="noreferrer">here</a>:</p>
  <pre><code>triggers {
      githubPush()
      githubPullRequest {
          useGitHubHooks()
          extensions {
              'org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus' {
                  buildStatus {
                      'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage' {
                          message 'Build in progress...'
                          result 'PENDING'
                      }
                      'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage' {
                          message 'Build succeeded! It is safe to merge ${ghprbSourceBranch} into ${ghprbTargetBranch}.'
                          result 'SUCCESS'
                      }
                      'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage' {
                          message 'Build failed.'
                          result 'FAILURE'
                      }
                      'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage' {
                          message 'Build errored. This is probably a problem with Jenkins or related infrastructure and not an issue with your code changes.'
                          result 'ERROR'
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  <p>But that did not help either; the failure is essentially the same:</p>
  <pre><code>ERROR: (build.groovy, line 9) No signature of method: javaposse.jobdsl.dsl.helpers.triggers.TriggerContext.org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus() is applicable for argument types: 
  (build$_run_closure1$_closure2$_closure10$_closure11$_closure12) values: 
  [build$_run_closure1$_closure2$_closure10$_closure11$_closure12@707221f0]
  </code></pre>
  <p>Line 9 is:</p>
  <pre><code>'org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus' {
  </code></pre>
  <p>Amidst all of this, I'm struggling to understand the differences between a buildStatus, commitStatus, completedStatus, etc. What do these things mean?</p>
  <p>Meanwhile, I reverted the DSL to the version without any <code>buildStatus</code> and tried creating a PR to see if it would trigger a build. It did not. I checked the &quot;GitHub Hook Log&quot;:</p>
  <pre><code>Started on Aug 4, 2020 6:16:47 PM
  Started by event from 10.101.32.177 ⇒ https://my-jenkins-host.com/github-webhook/ on Tue Aug 04 18:16:47 UTC 2020
  Using strategy: Default
  [poll] Last Built Revision: Revision 91170fb44c40737a6410acfba820d6555a0475bb (refs/remotes/origin/dev)
  using credential my-credential-id
   &gt; git --version # timeout=10
  using GIT_ASKPASS to set credentials 
   &gt; git ls-remote -h -- git@github.com:privateorg/myrepo.git # timeout=10
  Found 64 remote heads on git@github.com:privateorg/myrepo.git
  Ignoring refs/heads/branch1 as it doesn't match any of the configured refspecs
  Ignoring refs/heads/branch2 as it doesn't match any of the configured refspecs
  ...
  Ignoring refs/heads/branch64 as it doesn't match any of the configured refspecs
  Done. Took 0.71 sec
  No changes
  </code></pre>
  <p>Maybe the Hook Log isn't the right place to look, but the use of <code>-h</code> in the call to <code>git ls-remote</code> caused it to only list branches -- not PRs. If I use the same command locally but without <code>-h</code>, PRs are listed that I am confident would match my refspec.</p>
  <p>I originally encountered these problems using CloudBees Core Client Master version 2.204.3.7, revision 3. Upgrading to latest (2.235.2.3) did not help.</p>
  <p>Plugin versions in use:</p>
  <ul>
  <li>Job DSL: 1.77</li>
  <li>GHPRB: 1.42.1</li>
  </ul>
  <p>If there are other plugins in play that are relevant here, let me know and I'll add them.</p>
  <p>Summary of my questions:</p>
  <ol>
  <li>What is the correct syntax to configure custom status messages that will display in GitHub?</li>
  <li>What's wrong with my otherwise-valid config such that polling for remotes ignores PRs, and that opening a new PR doesn't trigger a build?</li>
  <li>Is there another place I should be looking for documentation for these things? Or other resources that would help me learn what I'm doing?</li>
  </ol>