azure-devopsazure-pipelinesazure-pipelines-yamlazure-pipelines-tasks

ADO Pipeline "Mapping values are not allowed in this context."


I'm getting the followin error when running a pipeline in ADO:

azure-pipeline-flex.yml: (Line: 23, Col: 22, Idx: 490) - (Line: 23, Col: 22, Idx: 490): Mapping values are not allowed in this context.

I'm guessing the hierarchy is messed up between the "job" that has its steps defined in the definition, and the "job" that uses a template.

Pipeline definition is:

    trigger:
      - develop
    
    resources:
      repositories:
        - repository: templates
          type: git
          name: 'removed'
          path: removed
          ref: removed
    
    variables:
      artifactName: 'name'
    
    jobs:
      - job: copy_files
        displayName: 'Copy Files'
        pool: 'removed'
        steps:
          - task: CopyFiles@2
              displayName: 'Copy files to artifact staging'
              inputs:
                SourceFolder: '$(Build.SourcesDirectory)'
                contents: '**'
                TargetFolder: '$(Build.ArtifactStagingDirectory)'
          - task: PublishBuildArtifacts@1
            inputs:
              PathtoPublish: '$(Build.ArtifactStagingDirectory)'
              ArtifactName: 'artifact-name'
              publishLocation: '$(Build.ArtifactStagingDirectory)'
    
      - job: push_container
        displayName: 'Create and push Docker container'
        pool: 'removed'
        variables:
          - group: removed
        steps:
          - template: template_name
            parameters:
              artifactName: $(artifactName)

Any ideas how I can run both jobs?


Solution

  • This seems an indentation issue.

    Instead of:

        steps:
          - task: CopyFiles@2
              displayName: 'Copy files to artifact staging'  # ---------------> unindented
              inputs:                                        # ---------------> unindented
                SourceFolder: '$(Build.SourcesDirectory)'
                contents: '**'
                TargetFolder: '$(Build.ArtifactStagingDirectory)'
    

    Try:

        steps:
          - task: CopyFiles@2
            displayName: 'Copy files to artifact staging'
            inputs:
              SourceFolder: '$(Build.SourcesDirectory)'
              contents: '**'
              TargetFolder: '$(Build.ArtifactStagingDirectory)'