Branch names vs Tag names

I would like to structure my pipeline so that certain steps only execute when a new tag to master is pushed. The general flow is that feature branches are worked on and merged to master. Then when we are ready, we tag master and trigger a release.

However, when this is done, BUILDKITE_BRANCH and BUILDKITE_TAG both have the tag name. Is the intended behavior? I would have expected BUILDKITE_BRANCH to always be the name of a branch. I understand that branches and tags aren’t that different as far as git is concerned. But it would be helpful if there were a way to determine the base branch that the tag was made against.

Looking at the webhook payload that Github Enterprise sends, it looks like base_ref has the necessary information. Is this something that could be made available if BUILDKITE_BRANCH and BUILDKITE_TAG having the same value is the intended behavior?

1 Like

Hey @plannigan, sorry you’ve run into trouble here. This one’s definitely a little confusing :confused: Triggering a release from a tag against master is a pretty common practice. Hopefully we can help you get back on track :+1:

Due to how tags work in git, a branch is not easily inferred, nor is it required to check out a tag. For this reason we’re setting BUILDKITE_BRANCH and BUILDKITE_TAG to the same value. This is the intended behaviour. Our docs aren’t really clear on this and we’re updating them now.

If confirming the source branch is an important part of your build process, you could check that the ref that the tag points to exists in master. Another option would be to access the webhook payload in our GraphQL API.

If you’d like us to take a look at a specific build feel free to email support@buildkite.com :e-mail:

I sent an email but have seen this thread and wanted to comment. I can see that the tag and branch values are the same, the issue I have is then the checkout fails.

error: pathspec '2.1.1' did not match any file(s) known to git
🚨 Error: The global checkout hook exited with status 1

Then if I try and run a build for the specific commit hash which has the tag, the value always is null. Why if I start a new build on the branch which contains the tag with that specific build does the tag value not be set?

This is for a BitBucket Cloud integration if that helps.

Hello, @michael.proctor, and welcome to the community!
We’ve received your email, too, and we’re looking into the issue now. I’ll get back to you ASAP when I have more information.

Cheers!