Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to reference Bamboo plan variables in PowerShell script?

Beau March 14, 2016

I have a PowerShell script that needs to reference Bamboo Plan variables (the GUI page in Bamboo console that allows you to add variables).

What is the syntax I need to use in my PowerShell script for referencing Bamboo plan variables?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Steffen Opel _Utoolity_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 14, 2016

This is not well documented indeed - you need to replace dots with underscores, i.e. for a plan variable named your.plan.variable, which you would reference in a regular Bamboo task as ${bamboo.your.plan.variable}, the resp. PowerShell syntax for use within the Script task is $bamboo_your_plan_variable.

Beau March 14, 2016

Hi

Just to confirm. In my powershell script, I can use the following

$bamboo_abc (abc is defined in plan variables console)

I don't need brackets around it.

Steffen Opel _Utoolity_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 14, 2016

@Beau - yes, you don't need (and can't use) brackets around a variable in a PowerShell script, $bamboo_abc is the only valid syntax for a plan variable defined as abc.

Beau March 14, 2016

Hi @Utoolity [OPS]

I tried the following command in powershell and it didnt work. The error tells me there's a syntax error.

net localgroup "Remote Desktop Users" /add "abc.com\$bamboo_ad_security_group_admin"

Any idea why it doesn't work?

Beau March 14, 2016

My powershell script which calls another powershell script with the command net localgroup "Remote Desktop Users" /add "abc.com\$bamboo_ad_security_group_admin" in the script.

Do I need to pass the variable from one script to another?

Steffen Opel _Utoolity_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 15, 2016

@Beau - yes, I think the variables only work within the immediate script context of the Script task, i.e. they are presumably injected with the PowerShell Script scope and you need to pass them via arguments from one script to another accordingly.

Jon Olson July 13, 2016

Bamboo uses environment variables in windows so you can just use Get-Childitem env: to list all of them. Then access using something like $Env:bamboo_Account_Name 

TAGS
AUG Leaders

Atlassian Community Events