Bitbucket yaml file is not running inheritance function

yosser_mahfoudh January 20, 2025

Hello team,

I'm trying to work with anchors and inheritance in Bitbucket yaml file but I got this error 

 

There is an error in your bitbucket-pipelines.yml at [pipelines > branches > release > 1]. Step is empty, null, or missing.

               

 

  definitions:
    services:
      docker:
        memory: 1024  
    caches:
      sonar: ~/.sonar
      maven:  ~/.m2/repository
    steps:

 

      - step: &build-release-common

          name: Build and Test with Default Branches
          caches:
            - maven
          size: 2x  
          script:            
                - echo "Building and testing the project with release branches..."
   branches:
      "release":
        - step:
          <<: *build-release-common
          deployment: Staging
          name: "build and test"
          script:
            - echo "Deploying to Staging"

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 21, 2025

Hi Yosser,

This error usually indicates an issue with indentation. Indentation needs to be at least one space from the previous level, and for everything under - step: it needs to be at least three spaces. I normally use two and four spaces respectively.

Additionally, combining a YAML anchor for a step with an additional script is not going to work. Even with correct indentation, the step <<: *build-release-common is not going to be executed. When you use a YAML anchor in a step, you can only use overrides for things like the step name, deployment, trigger. You cannot add another script in that step.

An example that should work with correct indentation and no additional script under the anchor is the following:

definitions:
services:
docker:
memory: 1024
caches:
sonar: ~/.sonar
maven: ~/.m2/repository
steps:
- step: &build-release-common
name: Build and Test with Default Branches
caches:
- maven
size: 2x
script:
- echo "Building and testing the project with release branches..."

pipelines:
branches:
"release":
- step:
<<: *build-release-common
deployment: Staging
name: "build and test"

Please feel free to let me know if you have any questions!

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events