2016-11-08 20 views
0

我有困難的時候摸不着頭腦,我有以下PowerShell腳本,簡單的一個:如何在PowerShell中添加Atlassian Bamboo變量?

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

我wan't在$ BambooPath替換C:與 $ {\ StartFolder * bamboo.build.working.directory} *變量...任何人都有一個想法如何做到這一點?

+0

它是一個環境變量?在這種情況下$ env:bamboo.build.working.directory – 4c74356b41

+0

它只是一個Bamboo變量 – MihaiAlex1986

+0

https://answers.atlassian.com/questions/37848637/how-to-reference-bamboo-plan-variables-in-powershell-腳本 $ bamboo_build_working_directory? 也看看這個:https://answers.atlassian.com/questions/256108/in-bamboo-how-can-you-accessedit-plan-and-global-variables-in-windows-powershell-script – 4c74356b41

回答

0

如果您有內聯PS腳本,您可以指定參數(有參數字段):

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

,並添加你的腳本應該像

param (
    [string]$BambooPath = "" 
) 

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

使用下劃線代替點訪問竹環境變量:

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