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: 

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

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

DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events