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?
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.
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:
http://alblue.bandlem.com/2011/04/git-tip-of-week-tags.html
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks 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
pipelines:
tags:
release_*: #this is using for each new release.."*" is the issue.
- step:
caches:
- maven
script
- 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
image: :my-java-image-v1
pipelines:
develop:
- step:
caches:
- maven
script
- mvn -B clean install -Dmaven.test.skip
- analyze-with-blackduck . #This is a cmd for blackduck scanner
#We mentioned scan information on docker image.
Script:
$BITBUCKET_BRANCH=${BITBUCKET_BRANCH:-$1} #working
$BITBUCKET_TAG=${BITBUCKET_TAG:-$1} #not working
echo $BITBUCKET_TAG
echo "TAG"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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_TAG | The tag of a commit that kicked off the build. This value is only available on tags. |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
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.