【问题标题】:How do you add Atlassian Bamboo variable in PowerShell?如何在 PowerShell 中添加 Atlassian Bamboo 变量?
【发布时间】:2016-11-08 14:30:29
【问题描述】:

我很难弄清楚这一点,我有以下 powershell 脚本,很简单:

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

我不想在 $BambooPath 中将 C:\StartFolder* 替换为 ${bamboo.build.working.directory}* 变量...有人知道怎么做吗?

【问题讨论】:

标签: powershell bamboo


【解决方案1】:

使用下划线而不是点来访问 Bamboo 环境变量:

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

【讨论】:

    【解决方案2】:

    如果你有内联 PS 脚本,你可以指定参数(有 Argument 字段):

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

    并添加你的脚本应该看起来像

    param (
        [string]$BambooPath = ""
    )
    
    $RemoteWebPath = 'C:\DestFolder'
    Copy-Item -Path $BambooPath -Destination $RemoteWebPath -Recurse
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      相关资源
      最近更新 更多