How can I get the default branch name from inside a pipeline? Our default branch name changes with every release.
I would like to be able to diff against the default branch to decide what part of the test suite to run when a new branch is pushed into the repo and before a PR is issued.
I looked everywhere and could not find it. If it does not exist, it would be nice to make this available as a REPO variable accessible from inside the pipeline.
Thank you for reaching out to the community.
Could you confirm if you're referring to the default branch name that is configured in your repository advanced settings?
Regards,
Mark C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the info, @Brigitte Bedard
Unfortunately, default main branch is not available as part of default environment variables in Bitbucket Cloud Pipelines.
You can, however, try to get the data by using the below API endpoint extracting the "mainbranch" field value and saving it as an environment variable in your build.
/repositories/{workspace}/{repo_slug}
Here's also an example on how to do that: https://confluence.atlassian.com/bbkb/obtaining-step-names-as-environment-variables-in-bitbucket-cloud-pipelines-1365016813.html
Regards,
Mark C
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.