如何解决Azure Yaml Pipelines Powershell任务参数中的MissingEndParenthesisInExpression问题 [英] How to troubleshoot MissingEndParenthesisInExpression in Azure Yaml Pipelines powershell task arguments

查看:43
本文介绍了如何解决Azure Yaml Pipelines Powershell任务参数中的MissingEndParenthesisInExpression问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

yaml PowerShell任务看起来像这样:

yaml PowerShell task looks something like this:

- task: PowerShell@2
  displayName: 'test'
  inputs:
    targetType: filePath
    filePath: '$(Agent.BuildDirectory)\$(artifactName)\testpath\testscript.ps1'
    arguments: '-parameterFilePath $(Agent.BuildDirectory)\$(artifactName)\mainfolder\params.json -appSecurePassword (convertTo-SecureString $(appPassword) -AsPlainText -Force) -vmSecurePassword (convertTo-SecureString $(vmPassword) -AsPlainText -Force)'

但是,出现此错误:

2020-06-09T12:54:59.6954669Z在C:\ agent_work_temp \ 66085384-0a17-4183-9832-42c481b13a84.ps1:3字符:352
2020-06-09T12:54:59.6974788Z + ... urePassword(convertTo-SecureString *** -AsPlainText -Force)
2020-06-09T12:54:59.7070327Z +〜
2020-06-09T12:54:59.7124752Z表达式中缺少结束')'.
2020-06-09T12:54:59.7142356Z + CategoryInfo:ParserError:(:) [],ParseException
2020-06-09T12:54:59.7161695Z + FullyQualifiedErrorId:MissingEndParenthesisInExpression
2020-06-09T12:54:59.7173148Z
2020-06-09T12:54:59.8102255Z ## [error] PowerShell退出,代码为"1".

2020-06-09T12:54:59.6954669Z At C:\agent_work_temp\66085384-0a17-4183-9832-42c481b13a84.ps1:3 char:352
2020-06-09T12:54:59.6974788Z + ... urePassword (convertTo-SecureString *** -AsPlainText -Force)
2020-06-09T12:54:59.7070327Z + ~
2020-06-09T12:54:59.7124752Z Missing closing ')' in expression.
2020-06-09T12:54:59.7142356Z + CategoryInfo : ParserError: (:) [], ParseException
2020-06-09T12:54:59.7161695Z + FullyQualifiedErrorId : MissingEndParenthesisInExpression
2020-06-09T12:54:59.7173148Z
2020-06-09T12:54:59.8102255Z ##[error]PowerShell exited with code '1'.

有人可以让我知道我在想什么吗?我确信PowerShell脚本没有问题,因为我可以在代理上手动运行它.

Can anyone please let me know what I am missing? I am sure there is no problem with the PowerShell script as I can run that manually on the agent.

推荐答案

上述错误消息 ... urePassword(convertTo-SecureString *** -AsPlainText -Force)表示问题来自powershell任务的 arguments .

The above error message ... urePassword (convertTo-SecureString *** -AsPlainText -Force) indicates the issue comes from the arguments of powershell task.

并且表达式中 Missing close')'的错误表示您的密码中包含("字符.

And the error Missing closing ')' in expression indicates that there is "(" character in your Password.

我在管道上进行了测试,如果密码是"pass(word" (不带双引号).我收到相同的 Missing close')'错误消息.

I tested on my pipeline, if my password is "pass(word"(without double quotes). I got the same Missing closing ')' error message.

自变量中引用密码时,可以尝试双引号.见下文:

You can try double quoting your passwords when you refer to them in the arguments. See below:

-appSecurePassword (convertTo-SecureString "$(appPassword)" -AsPlainText -Force) -vmSecurePassword (convertTo-SecureString "$(vmPassword)" -AsPlainText -Force)

您也可以尝试使用反引号转义密码中的特殊字符.例如,在管道变量中定义的密码中转义特殊字符(例如"pass`(单词" )

You can also try using backtick to escape the special characters in the password. For example, escape the special characters in the Passwords defined in the pipeline Variables (eg. "pass`(word")

请参见包含特殊字符的密码PowerShell 以获取更多信息.

See Passwords Containing Special Characters In PowerShell for more information.

这篇关于如何解决Azure Yaml Pipelines Powershell任务参数中的MissingEndParenthesisInExpression问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆