The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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?
Hi Milosz,
You can truncate the BITBUCKET_COMMIT variable inside of your pipeline script.
For example:
pipelines:
default:
- step:
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
Thanks,
Phil
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As a quick ref, this works too for at least bash
export BITBUCKET_COMMIT_SHORT="${BITBUCKET_COMMIT::7}"
Details http://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Parameter-Expansion
Agree with @Alexander Weickmann
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can get your git commit pretty format with the following:
- export COMMIT=$(git log --pretty=format:'%h' -n 1)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.