Getting the destination commit SHA for a PR in Pipelines

Adam Fenton August 5, 2020

Hi all,

Bitbucket Pipelines question here:

I'm trying to get the commit hash of the head of the destination branch of a PR. I can see the current commit is available in $BITBUCKET_COMMIT and the destination branch name is in $BITBUCKET_PR_DESTINATION_BRANCH, but how can I get the head commit of the destination branch?

I need this to fully take advantage of Happo for UI screenshot testing.

Thanks in advance.

1 answer

1 accepted

2 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 14, 2020

Hi Adam,

You can use in your bitbucket-pipelines.yml file the following command, in order to get the hash of the last commit in the destination branch:

git rev-parse origin/$BITBUCKET_PR_DESTINATION_BRANCH

Please feel free to let us know if this works for you and if you need anything further!

Kind regards,
Theodora

Adam Fenton August 14, 2020

Perfect, this works nicely. Thank you Theodora!

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 17, 2020

You are very welcome, glad to have helped!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events