The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

What is the environment variable BITBUCKET_PR_DESTINATION_COMMIT?

Tim Haines [Percy]
May 4, 2019

I noticed Bitbucket Pipelines builds for pull requests have an undocumented environment variable BITBUCKET_PR_DESTINATION_COMMIT.  What is it set to?  Is it always the most recent commit on the destination branch?

 

Is there any way to get what git would report as the merge_base or common ancestor commit?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Steven Vaccarella
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 9, 2019

It is the commit on the destination branch that gets merged into the source branch before running your build script. That's generally the latest commit on the destination branch, but if you rerun an old pipeline then it will be the same commit that was used on the first run (so you should always expect to get the same result when you rerun, even if the destination branch has changed since the first run).

If you want the merge base, you should be able to run the git merge-base command within your pipeline. Try this:

git merge-base $BITBUCKET_COMMIT $BITBUCKET_PR_DESTINATION_COMMIT
Tim Haines [Percy]
May 9, 2019

Thank you @Steven Vaccarella !  I asked a similar but different question too earlier - would you be able to help me out with this one please?  https://community.atlassian.com/t5/Bitbucket-questions/Bitbucket-Cloud-API-retrieve-the-merge-base-commit/qaq-p/1067228

TAGS
AUG Leaders

Atlassian Community Events