Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Run custom pipeline with specific tag


Hello Community,

my scenario is as follows: 

1) I would like to run a pipeline on a user specified tag. 

I've set up a custom pipeline with an input variable, requiring to enter a tag version (TAG_VERSION) to run the build on.

As far as I can see, the pipeline initially checkouts out the full branch, so therefore I added a this line as a step:

- git fetch --all --tags && git checkout $TAG_VERSION -b $TAG_VERSION


This seems to be superfluous, if I could initially set the pipeline's checkout command to perform the checkout only on TAG_VERSION.

2) Is it possible to provide a Dropdown "Run Pipeline" (instead of a plain text field) in the input field showing all available tags ?  


Thank you for your support!

1 answer

0 votes

Hi Andreas,

Custom builds run on a detached head. They do not run on a specific branch, therefore there will be no checkout to any branch. If you need to create and checkout to a branch, you'll need to use a command like the one you posted here.

The variables used in custom builds allow the user to give any input, I'm afraid that it is not possible to specify a dropdown for a variable with all available tags, or any user defined values. If you'd be interested in that, you are more than welcome to open a feature request for this in our issue tracker for our product managers to take into account, or I can open it also for you, just let me know!

Kind regards,

Hello Theodora,

thank you for your message.

As for Question 1:

In order to ensure my custom build to run on the correct branch (master), should I actually have to put the command in front of 

- git checkout master && git fetch --all --tags && git checkout $TAG_VERSION -b $TAG_VERSION

As far as I understand "Detached Head", it's checked out on a commit...

And for Question 2, yes please open a feature request for this, thank you!


Kind regards,


Hi Andreas,

Since custom builds will run on a specific commit, they will not be associated with a branch. What I mean by that is that if you go the Pipelines page of the repo, and select the master branch, you will not see any custom builds that were run on commits of master.

The command you included in your reply first checks out master branch but then creates and checks out a new branch. Whether you need to checkout/create a branch depends on what operations you do during your build and whether you need those branches. Do you need both master and a new branch on the tag during your build?

If you don't need these branches and you want to run a custom build on a tag, you can search for the commit with this tag in the Commits page of the repo and run the custom build on this commit. Then the checkout happens on the commit with this tag.

Kind regards,

Hi @Theodora Boudale , I came across this thread as we are searching for an answer on this too. 

You mentioned following in your reply dated on Oct 05, 2020:

"The variables used in custom builds allow the user to give any input"


Does that mean bitbucket pipeline is able to ask for user input amid a pipeline run? If so, can you show me an example or any documentation about this please? Many thanks.

Hi @binjie zhao,

If you use Pipelines with the keyword custom, you can define variables that you provide when you trigger the build (not in the middle of the build, but when you trigger the build manually). You can check the documentation below:

You can also check the screenshot on the following page (the image before the section "On schedule":

Please note that custom pipelines do not run automatically. You can trigger them manually from our website, via API, or as a scheduled pipeline.

Kind regards,

Thanks a lot @Theodora Boudale . I will give it a bash.

Like Theodora Boudale likes this

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events