小编Emr*_*mre的帖子

Azure Devops yaml构建定义PowerShell内联语法问题

我正在从经典构建系统(Azure Devops 中的任务定义)迁移到 yaml 构建定义,并在以下错误中运行。我能够在执行 PowerShell 脚本时分解错误,并发现 yaml 文件中的语法问题。

我使用 PowerShell 内联步骤,如下所示:

name: 1.1$(Rev:.r)

jobs:
- job: build
steps:
- task: PowerShell@2
    displayName: 'Test'
    inputs:
    targetType: 'inline'
    script: '$var1 = "valueVar1" 
             $var2 = "valueVar2"'
Run Code Online (Sandbox Code Playgroud)

当我运行命令时,我在 Azure Devops 中收到以下错误。

2019-12-07T18:39:15.3306239Z At D:\A\01\_temp\298966df-c117-432b-b4c1-17b4ece9d7f4.ps1:2 char:21
2019-12-07T18:39:15.3306715Z + $var1 = "var1Value" $var2 = "var2Value"
2019-12-07T18:39:15.3306784Z +                     ~~~~~
2019-12-07T18:39:15.3306847Z Unexpected token '$var2' in expression or statement.
2019-12-07T18:39:15.3307001Z     + CategoryInfo          : ParserError: (:) [], ParseException
2019-12-07T18:39:15.3307719Z     + FullyQualifiedErrorId : UnexpectedToken
2019-12-07T18:39:15.3308055Z  
2019-12-07T18:39:15.4085556Z ##[error]PowerShell exited with code …
Run Code Online (Sandbox Code Playgroud)

powershell yaml build azure-devops azure-pipelines

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

azure-devops ×1

azure-pipelines ×1

build ×1

powershell ×1

yaml ×1