Include system variable in global variable

Is it possible to create a new global variable which includes a system variable?

For example, I want to create a global variable for MSBuild options that I can use with each of my projects. In this global variable, I want to reference ${bamboo.buildnumber}. When I include the system variable, it does not get evaluated though. It's coming through as -Version "1.0.${bamboo.buildNumber}"

Is there a way to have this evaluated?

3 answers

1 accepted

1 vote
Accepted answer

You could potentially just use 2 variables... use the global variable for the first 2 numbers of your version number, and then use the ${bamboo.buildNumber} as the 2nd variable...

so in your scripts or where you pass arguments instead of passing in a single bamboo variable for the version, you can just concat 2 of them together

${bamboo.buildNumberPrefix}.${bamboo.buildNumber}

That's what I ended up doing, and that worked as I wanted. Thanks.

I am assuming that you have a build script that is a part of your repositor that you are executing. If you have the ${bamboo.buildNumber} in there, then it will not be resolved.

The ${bamboo.buildNumber} variable will be resolved when you pass it in as an argument to your script when your task executes it, or if you use inline scripting option as a task.

It's not a script. In Bamboo, I go to Administration->Global Variables and add the variable with text "/p:Version=1.0.${bamboo.buildNumber}". Then I go to my Plan->Configure Plan->Stages->Default Job->Tasks->MSBuild, and enter ${bamboo.myMsBuildOptions} in the Option text box. The string that gets passed to MSBuild includes the variable NAME ${bamboo.buildNumber} , not the variable value. This does NOT get parsed into "1.0.43" like I'd expect.

0 votes

What you'd need is nested evaluation of variables, which is not supported atm. You can create an improvement request for it here: jira.atlassian.com .

Suggest an answer

Log in or Sign up to answer
Community showcase
Asked Thursday in Jira Ops

I'm John Allspaw, Ask Me Anything about incident analysis and postmortems

I'm John Allspaw, co-founder of   Adaptive Capacity Labs, where we help teams use their incidents to learn and improve. We bring research-driven methods and approaches to drive effective inciden...

1,550 views 8 7
View question

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