Include system variable in global variable

Rob Gibbens October 16, 2012

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
Answer accepted
Cameron Ferguson
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.
October 17, 2012

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}

Rob Gibbens October 17, 2012

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

0 votes
Przemek Bruski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 16, 2012

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 .

0 votes
Cameron Ferguson
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.
October 16, 2012

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.

Rob Gibbens October 16, 2012

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events