Azure DevOps YAML Pipeline Error: While parsing a block mapping did not find expected key
Azure DevOps YAML Pipeline Error: 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):解析块映射时,未找到预期的键。”。我已经验证了我的 YAML 文件的缩进,看起来不错。
下面是我的 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
这是因为 PathtoPublish
的任务 PublishBuildArtifacts@1
中缺少引号。我通过使用 RedHat
.
提供的 YAML
扩展发现了这个错误
启用该扩展并设置 YAML 格式 (SHIFT + ALT + F) 后,它应该会显示 YAML 文件中的错误。
我刚刚使用 YAML 文件创建了一个管道,但我总是收到错误“/_Azure-Pipelines/templates/webpart.yml: (Line: 41, Col: 27, Idx: 1058) - (Line: 41,Col:60,Idx:1091):解析块映射时,未找到预期的键。”。我已经验证了我的 YAML 文件的缩进,看起来不错。
下面是我的 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
这是因为 PathtoPublish
的任务 PublishBuildArtifacts@1
中缺少引号。我通过使用 RedHat
.
YAML
扩展发现了这个错误
启用该扩展并设置 YAML 格式 (SHIFT + ALT + F) 后,它应该会显示 YAML 文件中的错误。