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?
You can truncate the BITBUCKET_COMMIT variable inside of your pipeline script.
- export BITBUCKET_COMMIT_SHORT=$(echo $BITBUCKET_COMMIT | cut -c1-7)
You can see other examples of how to do this here: https://stackoverflow.com/questions/8928224/trying-to-retrieve-first-5-characters-from-string-in-bash-error
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.
As a quick ref, this works too for at least bash
Agree with @Alexander Weickmann
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...
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