Identical tasks in plans, just the variables different - how best to implement?
Asked by Philip Colmer:

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.


Answers:
author: Steffen Opel _Utoolity_
body: 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](https://confluence.atlassian.com/bamboo/using-plan-branchese-289276872.html#Usingplanbranches-Manualbranchmanagement), and then override the variables in the [plan branch details configuration](https://confluence.atlassian.com/bamboo/using-plan-branchese-289276872.html#Usingplanbranches-Branchdetailsconfiguration):  

![bamboo-plan-branch-variables-override.png](https://community.atlassian.com/t5/image/serverpage/image-id/3893i5FD578453937E5C6/image-dimensions/428x165?v=v2 "bamboo-plan-branch-variables-override.png")

comments: author: Philip Colmer
body: 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.


author: Philip Colmer
body: 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.


author: Steffen Opel _Utoolity_
body: Thanks for the follow-up [@Philip Colmer](/t5/user/viewprofilepage/user-id/510078), using plan branches without the main plan is a neat approach I never even considered!


author: Grzegorz Lewandowski
body: 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)
```

<br />

You can read more about Bamboo Specs [here](https://confluence.atlassian.com/bamboo/bamboo-specs-894743906.html) and [here](https://docs.atlassian.com/bamboo-specs-docs/latest/)

comments: author: Philip Colmer
body: 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.