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...
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).
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.