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

BITBUCKET_COMMIT variable - short (7digits) in pipelines

I would like to use 'BITBUCKET_COMMIT' variable in pipelines to create unique file name. The problem is, that 40-digits SHA is not convinient to use in file names.


Is it possible to use 7-digits SHA environment variables? Or any way to process it in YAML?

3 answers

5 votes

Hi Milosz,

You can truncate the BITBUCKET_COMMIT variable inside of your pipeline script.

For example:

- step:
- ...

You can see other examples of how to do this here:



Would be easier if pipelines would that work already for us. Also, for pipelines it would be easy to use git commands instead of bash tricks. Git has a "safety" mechanism that will make the short commit hashes it hands out longer if the default 7 chars are not unique.

Like # people like this

As a quick ref, this works too for at least bash



Agree with @Alexander Weickmann 

You can get your git commit pretty format with the following:

- export COMMIT=$(git log --pretty=format:'%h' -n 1)

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,741 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