In Bamboo how can you access\edit plan and global variables in windows powershell script

I'd like to be able to read and update plan and global variables from PowerShell scripts. Ive seen that you should be able to take a variable like

bamboo.buildNumber

and access it in script by using

$bamboo_buildNumber

and i've also seen that you need to do

$BAMBOO_BUILDNUMBER

but neither is working for me.

What's the correct way to access these varialbes? And can you set them and then have that value available to other tasks, stages, deployment projects, ect...

1 answer

This widget could not be displayed.

If you run it as a Script command or pass in as arguments you can use Bamboo Variables in PowerShell. No matter where you use bamboo variables the format is the same

${bamboo.buildNumber}

If you continue to have problems, make sure to check the log as it shows which variables it's substituting before calling anything:

command	29-Jan-2014 09:24:36	Substituting variable: ${bamboo.buildKey} with TOOLS-TINK-BUILD
command	29-Jan-2014 09:24:36	Substituting variable: ${bamboo.buildNumber} with 2
command	29-Jan-2014 09:24:36	Substituting variable: ${bamboo.buildTimeStamp} with 2014-01-29T09:24:21.118-05:00
command	29-Jan-2014 09:24:36	Substituting variable: ${bamboo.repository.revision.number} with 187290
command	29-Jan-2014 09:24:36	Substituting variable: ${bamboo.repository.branch.name} with Trunk
As for editing, there is a plugin that can inject variables from a text file which you could create with PowerShell; personally, I've got inconsistent results with it so I abandoned it but here it is: https://marketplace.atlassian.com/plugins/com.atlassian.bamboo.plugins.bamboo-variable-inject-plugin. I'm not sure if the API will allow changes to any Global Variables or if it does whether the changes would be available in the same build in a later step (might cache).


Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

171 views 1 3
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