Run custom pipeline with specific tag
Asked by Andreas Siegert:

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!


Answers:
author: Theodora Boudale
body: 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 <https://jira.atlassian.com/secure/Dashboard.jspa> for our product managers to take into account, or I can open it also for you, just let me know!

Kind regards,  
Theodora

comments: author: Andreas Siegert
body: 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,

Andreas


author: Theodora Boudale
body: 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,  
Theodora


author: binjie zhao
body: Hi [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) , 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](https://community.atlassian.com/t5/Bitbucket-questions/Re-Run-custom-pipeline-with-specific-tag/qaq-p/1498449/comment-id/58502#M58502):

"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.


author: Theodora Boudale
body: Hi [@binjie zhao](/t5/user/viewprofilepage/user-id/5017105),

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:

* <https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/#variables>

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

* <https://support.atlassian.com/bitbucket-cloud/docs/pipeline-triggers/>

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,  
Theodora


author: binjie zhao
body: Thanks a lot [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) . I will give it a bash.


Tags: bitbucket-cloud

bitbucket-pipelines

cloud

git