Bitbucket Branch Source plugin automatically exposes several environment variables:
- BRANCH_NAME
- CHANGE_ID
- CHANGE_TARGET
- CHANGE_BRANCH
- CHANGE_FORK
- CHANGE_URL
- CHANGE_TITLE
- CHANGE_AUTHOR
- CHANGE_AUTHOR_DISPLAY_NAME
- CHANGE_AUTHOR_EMAIL
- TAG_NAME
- TAG_TIMESTAMP
- TAG_UNIXTIME
- TAG_DATE
and CHANGE_ID seems actually pull request id
Example of output of small test script is:
>>>>>>>>>>>>>>>>>>>>>BRANCH_NAME: PR-5 [Pipeline] echo >>>>>>>>>>>>>>>>>>>>>CHANGE_ID: 5 [Pipeline] echo >>>>>>>>>>>>>>>>>>>>>CHANGE_TARGET: master [Pipeline] echo >>>>>>>>>>>>>>>>>>>>>CHANGE_BRANCH: PR-5 [Pipeline] echo >>>>>>>>>>>>>>>>>>>>>CHANGE_FORK: null [Pipeline] echo >>>>>>>>>>>>>>>>>>>>>CHANGE_URL: http://localhost:7990/bitbucket/projects/PROJECT_1/repos/rep_1/pull-requests/5/overview [Pipeline] echo >>>>>>>>>>>>>>>>>>>>>CHANGE_TITLE: feature-2 change #1 [Pipeline] echo >>>>>>>>>>>>>>>>>>>>>CHANGE_AUTHOR: Administrator [Pipeline] echo >>>>>>>>>>>>>>>>>>>>>CHANGE_AUTHOR_DISPLAY_NAME: null [Pipeline] echo >>>>>>>>>>>>>>>>>>>>>CHANGE_AUTHOR_EMAIL: null