[英]AzureDevOps Powershell task command line parameters are not properly rendered in Powershell script
我有一个 AzureDevops Powershell 任务,它将从 KeyVault 读取的值作为参数传递给脚本。 即使在 DevOps 任务中的变量周围使用双引号或单引号,脚本中的值也不正确。
我还需要做什么才能将这些值正确传递给脚本?
有一个较旧的类似问题,答案是双引号任务中的参数,我已经完成了,但无济于事。
示例 Powershell 任务:
ScriptArguments: -connectionString "$(ConnString)" -password "$(ConnStringPassword)"
存储在 KeyVault 中的示例值:
ConnString: Server=tcp:test-sqldb.database.windows.net,1433;Initial Catalog=TestDb;Persist Security Info=False;
ConnStringPassword: Pa$$w0rd
示例脚本:
param (
[string]$connectionString,
[string]$password
)
Write-Host "connectionString: $connectionString"
Write-Host "password: $password"
来自管道执行的示例 output:
connectionString: ***
password: Paw0rd
如果我按照以下@Thomas 的建议在管道任务中使用单引号:
示例 Powershell 任务:
ScriptArguments: -connectionString '$(ConnString)' -password '$(ConnStringPassword)'
来自管道执行的示例 output:
connectionString: ***
password: ***
@ShaykiAbramczyk 是正确的,秘密是不可见的。 然而,这些值在 Powershell 脚本中得到了正确使用。 我通过发布测试 output 文件并看到 KeyVault 值在 output 文件中验证了这一点。 以下参考给了我发布以查看值的想法,而不是尝试将它们回显或写入控制台。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.