MihaiAlex1986
MihaiAlex1986

Reputation: 51

How do you add Atlassian Bamboo variable in PowerShell?

I'm having hard times to figure this out, I have the following powershell script , simple one:

$BambooPath = 'C:\StartFolder\*'
$RemoteWebPath = 'C:\DestFolder'
Copy-Item -Path $BambooPath -Destination $RemoteWebPath -Recurse

I wan't to replace in $BambooPath the C:\StartFolder* with the ${bamboo.build.working.directory}* variable...anyone has an idea how to do that?

Upvotes: 2

Views: 4908

Answers (2)

mhu
mhu

Reputation: 18051

Use underscores instead of dots to access the Bamboo environment variables:

$BambooPath = $Env:bamboo_build_working_directory
$RemoteWebPath = 'C:\DestFolder'
Copy-Item -Path $BambooPath -Destination $RemoteWebPath -Recurse

Upvotes: 5

Alexander Burov
Alexander Burov

Reputation: 1322

If you have inline PS script, you can specify argument (there Argument field):

-BambooPath ${bamboo.build.working.directory}

and add your script should look like

param (
    [string]$BambooPath = ""
)

$RemoteWebPath = 'C:\DestFolder'
Copy-Item -Path $BambooPath -Destination $RemoteWebPath -Recurse

Upvotes: 1

Related Questions