Identical tasks in plans, just the variables different - how best to implement?

Philip Colmer
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.
August 1, 2017

We're using Bamboo to build Jekyll web sites from content in git repositories.

We've got develop & master branches, and staging & production web sites.

The tasks to build the web sites are identical for both - it is just the variables that change, to specify whether this is a staging build or a production build.

At the moment, I've got two separate plans - each with an identical set of tasks and slightly differing variables.

Is there a better way to do this? My concern is that I've got to keep the task configuration in sync and I'd prefer to try to have a "master" plan and then somehow specify the different variable values in order to generate the appropriate output.

Is that possible with Bamboo? Or am I thinking about this the "wrong" way?

Thanks.

 

2 answers

1 accepted

2 votes
Answer accepted
Steffen Opel _Utoolity_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 1, 2017

As long as you are only using long lived branches as outlined, you should be able to just use a single plan, create a manual plan branch, and then override the variables in the plan branch details configuration:

bamboo-plan-branch-variables-override.png

Philip Colmer
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.
August 2, 2017

This approach seems to be working well. At the moment, the main plan is referencing the develop branch and I've created a plan branch for the master branch.

I'm toying with the idea of removing the repository from the main plan, so that it never directly triggers, and then adding the develop branch as a second plan branch. That seems to be more consistent than the way I've got it configured at the moment.

Philip Colmer
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.
August 3, 2017

Just as a follow-up note, it is perfectly possible to remove the *trigger* from the main plan and add the develop branch as a second plan branch. It works well and BitBucket still recognises that a pull request against that branch is building even though the main plan isn't the one building it.

Steffen Opel _Utoolity_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 3, 2017

Thanks for the follow-up @Philip Colmer, using plan branches without the main plan is a neat approach I never even considered!

0 votes
Grzegorz Lewandowski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 2, 2017

You can also use Bamboo Specs which was released in Bamboo 6.0 and 6.1 to create Specs plans definition to provide a common definition and then create couple of separate plans which have different variables.  In this way you'll still have couple of separate plans but you won't need to have to keep them in sync since the definition will be generated by Bamboo Specs. 

 

Let's say:

public Stage getCommonStage(){
return new Stage() // configure here common parts of your plan
}


Plan prod = new Plan(...).stages(getCommonStage())
.variables(/*put variables here which are different for each plan*/)

Plan stage = new Plan(...).stages(getCommonStage())
.variables(/*put variable here which are different for each plan*/)

new BambooServer(...).publish(stage)
new BambooServer(...).publish(prod)


You can read more about Bamboo Specs here and here

Philip Colmer
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.
August 3, 2017

Thanks, Grzegorz, for the suggestion. I decided to go with plan branches in the end because it was easier to get that solution in place and we don't have any Java programmers here. The documentation seems to suggest other languages can be used but it isn't clear how to adapt and I had some tight deadlines to hit.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events