mohamicorp / stash-jenkins-postreceive-webhook

Webhook used to notify Jenkins when commits are made to Stash
Other
138 stars 100 forks source link

Webhook not sending pull request ID to Jenkins #181

Open alhanger opened 7 years ago

alhanger commented 7 years ago

Before our builds run Jenkins executes a Groovy script to set a description for the build which contains a hyperlink back to the pull request, as well as the pull request ID. A link to the pull request is still being set in the description, but the pull request ID is null. Here is the Groovy script.

def currentBuild = Thread.currentThread().executable
def PULL_REQUEST_URL = build.buildVariableResolver.resolve('PULL_REQUEST_URL')
def PULL_REQUEST_ID = build.buildVariableResolver.resolve('PULL_REQUEST_ID')
def description = "<a href='$PULL_REQUEST_URL'>PR #$PULL_REQUEST_ID</a>"
currentBuild.setDescription(description)

It is not clear if the resolve() method is returning null, or if the ID is simply not sent in the payload (my hunch is the latter). This recently started occurring after upgrading our version of Webhook to Jenkins. Any help is greatly appreciated.

r4d1um commented 7 years ago

https://dengelonsoftware.blogspot.de/2017/01/jenkins-pull-request-and-pipeline.html

Parameters Parameterize the build with the following options: PULL_REQUEST_URL : string PULL_REQUEST_ID: string PULL_REQUEST_TO_BRANCH: string

Need to be added to the Job Configuration