1
如何在我的發佈定義中的powershell腳本中使用祕密變量?VSTS Powershell祕密變數
我碰到this但它不起作用。新代理上不存在目錄"$($env:AGENT_HOMEDIRECTORY)\agent\worker\Modules"
。
訪問新主機上的祕密變量的正確方法是什麼?我的代理版本是2.114.0。
如何在我的發佈定義中的powershell腳本中使用祕密變量?VSTS Powershell祕密變數
我碰到this但它不起作用。新代理上不存在目錄"$($env:AGENT_HOMEDIRECTORY)\agent\worker\Modules"
。
訪問新主機上的祕密變量的正確方法是什麼?我的代理版本是2.114.0。
您可以通過PowerShell參數傳遞祕密變量的值。
例如:
變量:password (secret)
任務:PowerShell
參數:-pass $(password)
腳本:
Param(
[string]$pass
)
if ($pass) { Write-Host "variable is NOT null" }
if (!$pass) { Write-Host "variable is null" }
是否有訪問它在腳本中的方法 - 沒有通過它是一個參數? – Mardoxx
@Mardoxx不,您需要將它作爲參數傳遞。 https://github.com/Microsoft/vsts-agent/issues/145 –
NB:應該是一個'[SecureString]'而不是'[string]'。 https://github.com/PowerShell/PSScriptAnalyzer/blob/development/RuleDocumentation/AvoidUsingPlainTextForPassword.md – JohnLBevan