我有一个从Bamboo触发的PowerShell脚本,该脚本基本上接受3个字符串参数:
Param([string]$language, [string]$architecture ="x64", [string]$version)
$x64Path = "some path..."
$x86Path = "some path.."
$arguments = $language,$architecture,$version
If($architecture -eq "x64") {
Write-Host "Executing:" $x64Path" at x64 using" $language "and" $version
# & $x64Path $arguments
}
Else {
Write-Host "Executing:" $x86Path "at x86 using" $language "and" $version
# & $x86Path $arguments
}
例如,如果我从ISE运行PowerShell脚本,则:
.\MyScript.ps1 "JPN" "x64" "AB 6.0 R"
我将正确获得此输出:
Executing: some path... at x64 using JPN and AB 6.0 R
我用以下内容在Bamboo中创建了一个计划:
我已经尝试将变量(参数)添加为:
"${bamboo.Language}" "${bamboo.Architecture}" ${bamboo.Version}
和aso:
"${bamboo.Language}" "${bamboo.Architecture}" "${bamboo.Version}"
但是我总是得到相同的输出:
Executing: some path... at x64 using JPN and AB
注意,最后一个变量已删除(我没有完整的AB 6.0 R)]
这是Bamboo的错误,还是我做错了什么?还是有解决方法?
我怀疑用竹子替换变量后,引号会被剥夺(即,在将参数传递给Powershell之前。)>
向带有空格的参数中添加内部单引号:
"${bamboo.Language}" "${bamboo.Architecture}" "'${bamboo.Version}'"