Reputation: 21779
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.". I already verified the indentation of my YAML file and that looks fine.
Below is my YAML file.
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
Upvotes: 23
Views: 36838
Reputation: 23543
In case someone stumbles here, I used pip install yamllint
(Thanks for the recommendation @Sibeesh ! ( redhat site ) )
And in my particular case While parsing a block mapping, did not find expected key
was caused by bad indentation like ,
stages:
- stage: repo_deploy_poc
jobs:
- job: blah
steps:
- bash: |
echo "hello"
# echo "hmm"
# echo "nevermind"
echo "ok bye"
And looks like it did not like my #
not aligned with indentation so changed it to
stages:
- stage: repo_deploy_poc
jobs:
- job: blah
steps:
- bash: |
echo "hello"
# echo "hmm"
# echo "nevermind"
echo "ok bye"
And was fine.
Upvotes: 4
Reputation: 21779
It was due to a missing quotation mark in the task PublishBuildArtifacts@1
for the PathtoPublish
. I found this error by using a YAML
extension provided by RedHat
.
Once you enabled that extension and set the formatted for YAML (SHIFT + ALT + F), it should show you the errors in your YAML file.
Upvotes: 44