首页 > 解决方案 > 如何对 Azure Yaml Pipelines powershell 任务参数中的 MissingEndParenthesisInExpression 进行故障排除

问题描述

yaml PowerShell 任务如下所示:

- 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 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 表达式中缺少关闭“)”。
2020-06-09T12:54:59.7142356Z + CategoryInfo: ParserError: (:) [], ParseException
2020-06-09T12:54:59.7161695Z + FullyQualifiedErrorId: MissingEndParenthesisInExpression
2020-06-09T12:54:59.7106-3148Z
2020 09T12:54:59.8102255Z ##[error]PowerShell 以代码“1”退出。

谁能让我知道我错过了什么?我确信 PowerShell 脚本没有问题,因为我可以在代理上手动运行它。

标签: azure-devopsazure-pipelines

解决方案


使用 Azure YAML 管道进行调试的一种方法是在运行时在管道上选择“启用系统诊断”:

在此处输入图像描述

运行后,您可以下载日志:

在此处输入图像描述

下载后查看 azure-pipelines-expanded.yml 这将是您的管道正在运行的完整 yaml,其中包含所有模板。这应该让您全面了解正在执行的内容。


推荐阅读