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.
Thanks,
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.
Thanks,
L.
Hi Philip,
We have the
BITBUCKET_BRANCH
environment variable.
Is this not what you want?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
See Lukas's reply below. No, it does not work. It doesn't clean the branch name, e.g. "feature/my-branch-#ticket"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
4 years gone and still not there... even though repo_slug exists.... @davina any news on this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 https://stackoverflow.com/questions/47050589/create-url-friendly-slug-with-pure-bash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.