Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Getting the destination commit SHA for a PR in Pipelines

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

1 vote
Answer accepted

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:


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

Kind regards,

Perfect, this works nicely. Thank you Theodora!

You are very welcome, glad to have helped!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,725 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you