简体   繁体   English

Azure DevOps YAML 管道错误:解析块映射时未找到预期的密钥

[英]Azure DevOps YAML Pipeline Error: While parsing a block mapping did not find expected key

I just created a pipeline using the YAML file and I am always getting the error "/_Azure-Pipelines/templates/webpart.yml: (Line: 41, Col: 27, Idx: 1058) - (Line: 41, Col: 60, Idx: 1091): While parsing a block mapping, did not find expected key.".我刚刚使用 YAML 文件创建了一个管道,但我总是收到错误“/_Azure-Pipelines/templates/webpart.yml: (Line: 41, Col: 27, Idx: 1058) - (Line: 41, Col: 60 , Idx: 1091): 解析块映射时,没有找到预期的键。”。 I already verified the indentation of my YAML file and that looks fine.我已经验证了我的 YAML 文件的缩进,看起来不错。

在此处输入图像描述

Below is my YAML file.下面是我的 YAML 文件。

parameters:
  - name: azureSubscription
    type: string
  - name: cdnStorageAccount
    type: string
  - name: cdnResourceGroupName
    type: string
  - name: cdnEndpointName
    type: string
  - name: cdnProfileName
    type: string
  - name: sourceBranchTrigger
    type: string

stages:
  - stage: build_stage
    displayName: "Build"
    jobs:
      - job: build_job
        steps:
          - task: UseNode@1
            displayName: "Use Node 8.x"
            inputs:
              version: "8.x"

          - task: CmdLine@2
            displayName: "Build"
            inputs:
              script: |
                cd ./Webparts
                npm run build-server

          - task: PublishBuildArtifacts@1
            displayName: "Publish Build Artifact (Apps)"
            condition: ne(variables['Build.Reason'], 'PullRequest')
            inputs:
              PathtoPublish: "Webparts/sharepoint/solution/webpart.sppkg
              ArtifactName: Apps

          - task: PublishBuildArtifacts@1
            displayName: "Publish Build Artifact (Scripts)"
            condition: ne(variables['Build.Reason'], 'PullRequest')
            inputs:
              PathtoPublish: "Webparts/temp/deploy"
              ArtifactName: Scripts

It was due to a missing quotation mark in the task PublishBuildArtifacts@1 for the PathtoPublish .这是由于 PathtoPublish 的任务PathtoPublish PublishBuildArtifacts@1中缺少引号。 I found this error by using a YAML extension provided by RedHat .我通过使用RedHat提供的YAML扩展发现了这个错误。

在此处输入图像描述

Once you enabled that extension and set the formatted for YAML (SHIFT + ALT + F), it should show you the errors in your YAML file.一旦启用该扩展并设置 YAML 的格式(SHIFT + ALT + F),它应该会显示 YAML 文件中的错误。

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Yaml 文件中使用 powershell 内联脚本时出现错误“解析块映射时找不到预期的键” - when using powershell inline script in Yaml file I get error "while parsing a block mapping did not find expected key" 如何解决 Yaml 语法错误“未找到预期的密钥” - Azure devops - How to resolve Yaml syntax error 'did not find expected key' - Azure devops 扫描简单键时,找不到预期的“:”。 azure-pipeline.yaml 中的语法错误 - While scanning a simple key, could not find expected ':'. Syntax error in azure-pipeline.yaml YAML Azure DevOps 管道上的解析器错误 - YAML Parser error on Azure DevOps Pipeline Azure DevOps 管道 - YAML 格式错误? - Azure DevOps Pipeline - YAML formatting error? Azure Devops 管道 Yaml“切换块评论”不起作用 - Azure Devops pipeline Yaml 'Toggle Block Comment' not working 使用 Azure DevOps 管道模板中的“参数”部分时出现“预期映射”语法错误,用于 .NET 核心应用程序构建 - 'Expected a mapping' syntax error when using 'parameters' section in Azure DevOps pipeline templates for .NET Core app build 如何从 azure devops yaml 管道中的工件中找到 runID - How to find runID from artifact in azure devops yaml pipeline 如何解决“YAML 文件(Azure DevOps)中的意外值和映射错误” - How to resolve 'Unexpected value & mapping error in YAML file (Azure DevOps)' Azure 管道在解析管道时遇到错误 YAML(唯一作业名称) - Azure pipelines encountered error(s) while parsing pipeline YAML (Unique Job Name)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM