Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.". I already verified the indentation of my YAML file and that looks fine.

enter image description here

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
like image 349
Sibeesh Venu Avatar asked Sep 12 '25 16:09

Sibeesh Venu


1 Answers

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.

enter image description here

Once you enabled that extension and set the formatted for YAML (SHIFT + ALT + F), it should show you the errors in your YAML file.

enter image description here

like image 151
Sibeesh Venu Avatar answered Sep 15 '25 17:09

Sibeesh Venu