Marcie
Marcie

Reputation: 1259

YAML Implicit keys need to be on a single line, Implicit map keys need to be followed by map values

trigger:
- develop

pool:
  vmImage: windows-2019

- task: MSBuild@1
  inputs:
    solution: '**/*.sln'
- task: DownloadBuildArtifacts@1
  inputs:
    buildType: 'current'
    downloadType: 'single'
    itemPattern: '**/*.exe'
    downloadPath: '$(System.ArtifactsDirectory)'

I get an error with this YAML in both Azure DevOps and using the YAML extension for VS Code. I'm trying to build a Windows Service and then put the .exe file somewhere that I can download it.

Azure DevOps: azdo screenshot VSCode vscode screenshot

Error:

Implicit keys need to be on a single line, Implicit map keys need to be followed by map values

Upvotes: 7

Views: 42557

Answers (3)

user2453676
user2453676

Reputation: 552

When I ran into this error, it was caused by the next line having an extra level of indentation.

Exact error text:

Nested mappings are not allowed in compact mappingsYAML
Implicit keys need to be on a single line

Incorrect

    MultiStockQtysResponse:
      type: array
      items:
        type: object
          required: [standardID, storeCode, qtyAvailable]

Correct

    MultiStockQtysResponse:
      type: array
      items:
        type: object
        required: [standardID, storeCode, qtyAvailable]

The error started on the line with type: object, but un-indenting required... fixed the error.

Upvotes: 4

Daniel Hadad
Daniel Hadad

Reputation: 91

We've just run into the same error and it was being caused by invisible characters that appeared when we copied the code over from a Teams chat. We've removed these "spaces" and replaced them with regular spaces and it worked.

Upvotes: 3

promicro
promicro

Reputation: 1646

Although the error looks some what confusing, your are missing the keyword steps.


trigger:
- develop

pool: 
  vmImage: windows-2019

steps:
- task: MSBuild@1 
  inputs: 
    solution: '**/*.sln'
- task: DownloadBuildArtifacts@1 
  inputs: 
    buildType: 'current' 
    downloadType: 'single' 
    itemPattern: '**/*.exe' 
    downloadPath: '$(System.ArtifactsDirectory)' 

Upvotes: 7

Related Questions