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

can i configure bamboo plan branching to exclude running a job on the master branch?

AndyAtTogether March 3, 2013

I have a plan that i want to run no feature branches but i don't really want the plan to run on the master. Is there a way of configuring this>

8 answers

1 accepted

5 votes
Answer accepted
AndyAtTogether March 9, 2013

ok so the answer that i found that works (in case anyone else is interested) is to insert the regular expression ^((?!master).)*$ into the "Only Create Branches that Match" field on the branch configuration tab

Scott Butcher April 5, 2017

This method didn't work for me.  Bamboo did not use this regular expression to exclude branches.

1 vote
Hua Soon SIM _Akeles_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 12, 2019

The not so obvious way is to disable the plan.

Apparently, it does not disable the branch plan creation and execution.

When the master plan is disabled but configured with automatic branch management, a new branch plan will still be created. Commits to the branch will trigger a branch plan to run unless you explicitly disable that particular branch plan.

For details, refer to https://jira.atlassian.com/browse/BAM-20138

1 vote
Scott Butcher April 5, 2017

These steps work in Bamboo 5.12.  I have no idea what other versions of Bamboo are like.

1. In the Bamboo build plan, navigate to the Branches tab and select "Create plan branches for matching new branches" and add a regular expression, for example "^feature/".  Or you can select "Create plan branches for all new branches" and skip the regular expression.

2. If there isn't already a branch plan for master, add it manually using the "Create plan branch".

3. Navigate to the Branch details tab for the master branch plan and change the trigger type to manual.

1 vote
ArmenA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 17, 2013

Hi Vincent,

Currently Bamboo doesn't support conditional flow controls. You can achieve a similar goal by splitting your current plan into 2 plans (the one that contains the build & package part, and the other one that contains the rest). Next, add a Script task to be the last task in your first plan. In your script task write a small script that will check the plan variable that returns the branch name (bamboo.repository.branch.name), and if the branch name is not a specific one, use this command to trigger the second plan:

curl -X POST --user admin:admin "http://localhost:8085/rest/api/latest/queue/FOO-BAR?executeAllStages=true"

where "admin:admin" is the username and password, and "FOO-BAR" is the plan key you want to trigger. I know this doesn't look the exact action that you ment, but as I said, Bamboo doesn't support conditional controls.

Cheers,
Armen

Richard Cross September 26, 2016

I would not recommend the above if using Bitbucket (or Stash) with Pull Requests.  

Only the very first plan triggered by a code change will then report a "Successful Build" to Bitbucket; therefore someone could easily think a build was successful, only to find that the subsequent plan actually failed.

Ondra Medek July 31, 2018

Hm, putting admin user and pass into the bamboo script, ugh, it's a really dirty hack.

1 vote
ArmenA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 4, 2013

Yes, you can configure your plan branch to use any repository branch you want to. For more information, please refer to this page.

By the way, if you just want to checkout from the master branch and don't need other branch plan featuers, you can configure a specific branch (by default Bamboo uses the master branch) on the repository configuration page of a regular plan. For instance, if you use Git, you can specify the branch in the Branch field as it's mentioned in the documentation.

Cheers,
Armen

AndyAtTogether March 5, 2013

ok so the answer that i found that works (in case anyone else is interested) is to insert the regular expression ^((?!master).)*$ into the "Only Create Branches that Match" field on the branch configuration tab

Like Bilal Arshad likes this
javafun June 16, 2013

Hi Armen

I have a list of jobs, build&package, deploy to dev , deploy to stage etc. How can I configure the branch only run the first job - build & package, not the rest of the jobs?

Thanks

0 votes
Ciprian Diaconasu November 28, 2013

I'm trying to configure a plan to exclude branches that start with "hotfix". I'm using "Only create branches that match" "^((?!hotfix).)*$", but that plan still executes on branches like hotfix/ABC or hotfix-ABC.

Is this a bug on Bamboo or my regexp is not right (although all regexp parsers exclude strings like hotfix/ABC or hotfix-ABC on that regexp)?

ArmenA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 1, 2013

Hi Ciprian,

The regex is for creating plan branches, not for running them. If you create a branch in your repository and you want Bamboo to detect and automatically add the corresponding plan branch, that's when the configured regex will be used. However, if the plan branch is already created in Bamboo, the branch will run whenever it's triggered. Makes sense?

Armen

Ciprian Diaconasu December 1, 2013

Hey!

Thanks for your reply. So I'd have to delete the plans created automatically and new ones that don't match the regex should not be created automatically, right?

Ciprian

ArmenA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 1, 2013

You are right, Ciprian. You need to remove the old plan branches that shouldn't have been added to Bamboo. The new correct branches that you create in your repo will be added to Bamboo based on the configured regex.

Armen

Ciprian Diaconasu December 1, 2013

Thank you very much for your answer! Made my day!

Ciprian

0 votes
javafun June 13, 2013

Hi

I have a list of jobs, build&package, deploy to dev , deploy to stage etc. How can I configure the branch only run the first job - build & package, not the rest of the jobs?

pic1

javafun June 16, 2013

Anyone can give a suggestion?

0 votes
AndyAtTogether March 3, 2013

sorry that should read...

I have a plan that i want to run feature branches on but i don't really want the plan to run on the master. Is there a way of configuring this?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events