Unexpected type * encountered while reading 'resources'. The type 'MappingToken' was expected

Viewed 2125

Running pipeline from template cause this error: Unexpected type 'SequenceToken' encountered while reading 'resources'. The type 'MappingToken' was expected. Any idea how to fix it?

pipeline.yaml

trigger: none
resources:
  repositories:
    - repository: pipeline
      type: git
      name: MyProject/my-repo
      # My feature branch
      ref: refs/heads/feature/unit_test
extends:
  # Template that I'm extending
  template: pipelines/application.yaml@pipeline
1 Answers

I found the problem to this ridiculous error message. It turned out that when you extend pipelines with templates as I did template: pipelines/application.yaml@pipeline. You MUST get rid of trigger and resources keys in pipeline that you are extending it from.

application.yaml - Settings that caused the error.

trigger:
  - pipeline

resources:
  - repo: self

variables:
  commit: '$(Build.SourceVersion)'
  imageTag: 'latest'
  imageName: 'app-backend'
  imageArtifact: '$(imageName):$(imageTag)'

stages:
  - template: ../stages/build.yaml
  - template: ../stages/test.yaml

application.yaml - Settings that fixed the error.

variables:
  commit: '$(Build.SourceVersion)'
  imageTag: 'latest'
  imageName: 'app-backend'
  imageArtifact: '$(imageName):$(imageTag)'

stages:
  - template: ../stages/build.yaml
  - template: ../stages/test.yaml

Change makes sense since now your pipeline context is relative to your project, rather than the repository that you are extending it from.

Related