Search code examples
yamlbitbucketbitbucket-pipelines

What is wrong with bitbucket-pipelines.yml. "Expected a mapping or list of mappings for merging, but > found scalar"


I'm trying to figure out why is bitbucket pipelines cicd throwing yaml syntax errors for my pipeline.
Actual error message:

There is a YAML syntax error in your bitbucket-pipelines.yml at [line 3, column 13]. Expected a mapping or list of mappings for merging, but found scalar

Here's the actual bitbucket pipeline that I already simplified to a bare minimum.

definitions:
  steps:
    - step: &prep_base_images
      name: Docker compose build base images
      image: docker:latest
      deployment: test
      script:
        - echo "hello world"

# Actual pipelines
# ==============================================================================
pipelines:
  branches:
    BLAH-137-backend-and-cicd-update:
      - step:
          <<: *prep_base_images
          deployment: development

Bitbucket validator says "valid", but when I actually run the code -> I get a YAML syntax error... super weird.


Solution

  • Step definition is missing an indentation level.

    definitions:
      yaml-anchors:
        - &prep_base_images_step
            name: Docker compose build base images
            image: docker:latest
            deployment: test
            script:
              - echo "hello world"
    
    pipelines:
      branches:
        something/*:
          - step:
              <<: *prep_base_images_step
              deployment: development