Question about BITRISE_GIT_BRANCH env variable

Hi there,

We are using tags to trigger our build workflows. For our production builds, we are using the main branch, whilst our default branch for development and other builds is named dev. E.g., to kick off a production build, we apply a tag to the main branch and push it to our repo on Github.

We recently noticed that the $BITRISE_GIT_BRANCH environment variable is still set to dev, even when our tags that trigger a build are on the main branch and are building off from the main branch. Is this expected behavior? Does the environment variable get set by the trigger?

It doesn’t seem to cause any problems, but when we added the default Slack message step to our workflow, it contains $BITRISE_GIT_BRANCH in it, and it was a little disconcerting to see what appears to be the wrong branch in the notification.

Thanks,
Mike

Think I’m getting the same problem.

I have the following line in my Fastlane file which fails.

BUILD_NUMBER = sh("expr $(git rev-list origin/${BITRISE_GIT_BRANCH} --count) - $(git rev-list HEAD..origin/${BITRISE_GIT_BRANCH} --count)").chop

but, if I hard coded the parameter to the following, it works (???)

BUILD_NUMBER = sh("expr $(git rev-list origin/release/2.0.1 --count) - $(git rev-list HEAD..origin/release/2.0.1 --count)").chop

Hello,

$BITRISE_GIT_BRANCH used to always have a value, but could be incorrect iin case of commit or tag triggered with no explicit branch. It should now be blank in those cases.

For tag triggered builds, there is the $BITRISE_GIT_TAG contains the value of the tag

Hope this helps!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.