Hello,
I am trying to access the Pull Request Number from within my Jenkinsfile, 
so that my Multibranch Pipeline build can do interesting stuff with it 
(like post a comment to the PR). Unfortunately, although the documentation 
claims this is available in CHANGE_ID, I have not found this to be the 
case. I am running the newly refactored Multibranch Pipeline plugin.

Jenkins base version: 2.60.1
Pipeline:Multibranch plugin version: 2.16

My Jenkinsfile contains this code:

            echo "CHANGE_ID is ${env.CHANGE_ID}"
            echo "PULL_REQUEST is ${env.PULL_REQUEST}"

My Multibranch Pipeline project detects when I have created a PR branch, 
and it automatically builds the PR branch.
However, the build output contains this:

[Pipeline] echo
CHANGE_ID is null
[Pipeline] echo
PULL_REQUEST is null

I found this Stack Overflow article 

https://stackoverflow.com/questions/41695530/how-to-get-pull-request-id-from-jenkins-pipeline

which suggests I need to 
- Disable branch builds
- Enable PR builds
- Check a checkbox 'Build origin PRs (unmerged head)

^^ All of which appear to pertain to a January 2017 version (now 
deprecated) of the plugin.

Anyhow, as I said, my PR branch is being detected and built, but even 
dumping out 'env' did not show any env vars containing the PR number.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/bd781dee-fecb-426c-b618-e63a9e4512cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to