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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

When is BITBUCKET_TAG environment variable set?

This question is in reference to Atlassian Documentation: Environment variables in Bitbucket Pipelines

I've been experimenting with pushing commits and tags on master and other branches and I can't find a situation when the BITBUCKET_TAG environment variable is set.

 Under what scenario is the BITBUCKET_TAG set and triggers a pipelines build?


4 answers

0 votes

Bitbucket Pipelines currently doesn't build pushed tags (it only builds the top commit of the push). 

Is there anything specific you are trying to achieve with Bitbucket tags?

I was prototyping how to migrate our deployment pipeline from Bamboo Cloud using tags as the trigger on specific branches.   (qa branch, tagging RELEASE-X, triggers deployment)


FYI - the documentation I reference in the original post documents a BITBUCKET_TAG environment variable kicks off a build!


BITBUCKET_TAGThe tag of a commit that kicked off the build. This value is only available on tags.
Deleted user Aug 11, 2016

We are also attempting to use the BITBUCKET_TAG environment variable without success. Specifically, when a commit is pushed to master, we are using Pipelines to package our code and upload the archive file to Artifactory. The archive file needs to include the version number (i.e. the tag on master), but the BITBUCKET_TAG environment variable isn't being set.

On first read of Jeroen's answer he appears to suggest the env var BITBUCKET_TAG is pointless :)


I'm guessing you have to tag the commit locally prior to pushing the commit to the remote branch (Bitbucket). This would then kick off a build and have the tag available immediately.

I am facing issue with BITBUCKET_TAG, when I am trying to scan my tag branch using blackduck software it will show "missing argument" issue.Some one please help me.

Hi @Aruljothi J,

might be best to create a seperate question for this, since it is a different topic. 

Regarding your question, I am not entirely sure what blackduck software does, but keep in mind that the $BITBUCKET_TAG variable will only be set if you pushed a tag (i.e. not if you pushed a branch reference). 

Screen Shot 2018-05-31 at 1.15.37 PM.pngThanks for your response Jeroen.

I would like to elaborate my issue here.

#Blackduck is opensource security scan software, when I run my pipeline with "analyze-with-blackduck" it will scan my branches(master/develop/future) and create/send report to blackduck server.

"analyze-with-blackduck"-this is the command which I am using for my branch scanning.

It will scan for master/develop/future branches not for TAGS.

We had a shell script to detect and scan the branches not for tags, now I am trying to scan Tags also but it's shows error.

I have updated my pipeline.yml and script:

image: :my-java-image-v1



   release_*:  #this is using for each new release.."*" is the issue.

     - step:


           - maven


      - mvn -B clean install -Dmaven.test.skip

     - analyze-with-blackduck . #This is a cmd for blackduck scanner

 Below pipeline is using for develop, it's working 




     - step:


           - maven


      - mvn -B clean install -Dmaven.test.skip

     - analyze-with-blackduck . #This is a cmd for blackduck scanner

#We mentioned scan information on docker image.




$BITBUCKET_TAG=${BITBUCKET_TAG:-$1} #not working


echo "TAG"

This is similar with @[deleted] query.

So I ran into this issue where I was unable to get the BITBUCKET_TAG variable to be set, and there was a few things I had to figure out to get the Tag value to set properly. First, I learned about git tags through this link:

The important thing to take from that was the comment about annotated tags versus lightweight. E.g. If you want to have git tags that trigger pipeline builds you'll want to have a git workflow of something along of the lines of:

git add .

git commit -m "comment about commit"

git tag -a v1.2.3 -m "Comment about release" # Note the -a flag

git show #(to check and see if the tag is set on the commit)

git push --follow-tags # This pushes both the latest commits and flags

The push --follow-tags is the second thing I learned from doing it, and what this does is trigger two builds (Which I wasn't expecting, but better than not having the Tag value set ever):

- One for the fact that there was a push of commits, which will do a pipeline run with ONLY the BITBUCKET_BRANCH value set

- One for the fact a tag was pushed, which will run with ONLY the BITBUCKET_TAG value set.

So I'm not sure if this is 100% how it was intended to be done, but that's the only solution I could find. Hope it helps someone down the road.

It is my current understanding that the  BITBUCKET_TAG environment variable is set if the pipeline that runs is a "tag" pipeline.


The value of BITBUCKET_TAG parameter is the name of the git tag that triggered the pipeline.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

3,877 views 68 21
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you