michaelneale this happened with the older (as of whatever the latest version was) yesterday. I tested this today with a simple sh 'env' step after updating all of our plugins to the 2.0 line (based on this blog post) and now we see something like:
# ... some other env variables
CHANGE_URL=https://git.corp.com/projects/proj/repos/repository/pull-requests/4/overview
CHANGE_ID=4
BRANCH_NAME=PR-4
CHANGE_TITLE=This is the commit message in the PR
CHANGE_TARGET=master
I don't believe that CHANGE_TARGET was available before the plugin updates but I could be wrong. I don't see anything regarding the source branch in the PR available as an environment variable (may be separate from this issue).
Note that this is with Bitbucket Server 4.11 (not Bitbucket Cloud).
It looks like the env.BRANCH_NAME is not the origin branch in pull requests, it is the PR number.