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

Why is BITBUCKET_COMMIT short all of a sudden?

Joshua Behrens
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 5, 2023

I have scripts comparing BITBUCKET_COMMIT and git rev-parse. We noticed in a 1yo repository where we now added that kind of script, that BITBUCKET_COMMIT for whatever reason is now only 12 characters long. This way the short revision compared with the long revision from git rev-parse will never be equal again like this. Is this a change where I missed a memo? Which newsletter do I need to subscribe?

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 9, 2023

Hi Joshua,

Is the build that returns the short hash running on a pull-requests definition?

Builds that run on pull-requests will return a short hash for BITBUCKET_COMMIT. However, builds running on branches, tags, custom pipelines, and the default pipeline will return the full hash for BITBUCKET_COMMIT.

We have a bug report about this in our issue tracker:

Workaround:

You can use the following command in the script of that step, prior to using the variable:

- export BITBUCKET_COMMIT=$(git log -1 --format="%H" $BITBUCKET_COMMIT 2>/dev/null)

The variable BITBUCKET_COMMIT will then return the full commit hash.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events