Bamboo plan with a variable which depends on another variable, it works in some circumstances

I have a bamboo plan with a maven task. I need to pass a maven parameter with the name of the branch.

I can use the variable ${bamboo.repository.branch.name} for this.

However, I need to override this value for some branches (see https://answers.atlassian.com/questions/267198/bamboo-variable-regex).

So, in my bamboo plan I define a variable called "branchName", with value "${bamboo.repository.branch.name}".

then, my maven task uses ${bamboo.branchName}, and the branches can override the "branchName" value when neceserary.

So, is this possible? can my bamboo plan variable "branchName" use another variable "${bamboo.repository.branch.name}" as default value?

Well, I tried, and the result is unclear.

If my maven task is:

mvn verify -B -Dsonar.branch=${bamboo.branchName}

this does not work. it executes mvn verify -B -Dsonar.branch=${bamboo.repository.branch.name}

However,

If my maven task is:

mvn verify -B -Dsonar.branch=${bamboo.branchName} -Dignore_var=${bamboo.repository.branch.name}

then ${bamboo.branchName} gets substituted as expected,

and it executes mvn verify -B -Dsonar.branch=develop -Dignore_var=develop

Why is that? Is this a bug or a feature?

So, how to achieve this correctly?

that is, I need a bamboo plan variable "branchName" with a default value of "${bamboo.repository.branch.name}",

which can be overridden by branch plans.

2 answers

This widget could not be displayed.

You may want to try the nested plugin. That way you could set a variable to "${bamboo.repository.branch.name}" but when evaluated it will give you the value of the inner variable.

This widget could not be displayed.

thanks, we'll try that.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

131 views 2 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you