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?
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.