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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Bitbucket Pipeline BRANCH_SLUG

I see there is no BRANCH_SLUG environment variable. How do we create one?

Use case: we use feature/ branch and need to publish that into a URL format. There's a slug for repo name, but not branch name.


2 answers

I got into the same issue today. While BITBUCKET_BRANCH variable exists, it does not fit to our needs because it may contain characters which are not compatible or may break your url. I like the idea how gitlab handles refs. There's no branch or tag, there's just reference, which may be either the branch name, or the tag name. And there's also REF_SLUG, which is webalized version of the ref name:

Lowercased, shortened to 63 bytes, and with everything except 0-9 and a-z replaced with -. No leading / trailing -. Use in URLs, host names and domain names.

I know we can make this variable possible with usage of bash tools, but could be good to have ootb and same for all projects.




0 votes
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Nov 01, 2017

Hi Philip,

We have the 


environment variable.

Is this not what you want?

See Lukas's reply below. No, it does not work. It doesn't clean the branch name, e.g. "feature/my-branch-#ticket"

Like Pavel likes this

Come on, 3 years gone, and still no so needed variable?

4 years gone and still not there... even though repo_slug exists.... @davina any news on this?

As a temporary workaround you could process the BITBUCKET_BRANCH variable like this: 

BRANCH_SLUG="$(echo $BITBUCKET_BRANCH | iconv -t ascii//TRANSLIT | sed -r s/[~\^]+//g | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z)"

See also

Like # people like this

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events