title: Access BitBucket payload data in Jenkins pipeline job
body: <p>I've got a Jenkins pipeline job; it is configured to build on remote trigger which is being called by a BitBucket webhook. This works and is triggering the build.</p>
  
  <p>I also need to access the payload data sent by BitBucket (<a href="https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html#EventPayloads-Push" rel="noreferrer">described here</a>) to get details about the push such as the specific branch.</p>
  
  <p>The <a href="https://wiki.jenkins-ci.org/display/JENKINS/BitBucket+Plugin" rel="noreferrer">BitBucket plugin</a> would usually parse this payload and present it to the job as an environment variable, but I can't set the pipeline job as being connected to a specific repo for that plugin, so it doesn't help.</p>
  
  <p>I tried testing to see if the data was available in a few different ways like so:</p>
  
  <pre><code>node {
      stage 'Desperation'
  
      echo "${params.push}"
      echo "${env.BITBUCKET_PAYLOAD}"
      echo "${env.push}"
  }
  </code></pre>
  
  <p>These don't work (nor did I really expect them to).</p>
  
  <p>Is there any way to get hold of this payload data? The only thing I can come up with is having a freestyle job and setting up the connection to BitBucket on that, then calling this job afterwards with the data reformatted. That seems horribly clunky though.</p>