Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

YAML anchors, aliases & overrides

sureshh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 20, 2024

It's a great feature described at https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/.

But is it possible to use YAML anchors, aliases & overrides across multiple yaml files across different respositories?

Example, I want to define some common stages build pipeline config in common file and want to reuse it across multiple build yaml files which are part of different bitbucket repositories.

 

Thanks in advance.

1 answer

1 vote
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 21, 2024

Hi @sureshh 

Sure thing! We have this as a feature, you can read more about how to set this up and implement it within your workspace in the article below:

Cheers!

- Ben (Bitbucket Cloud Support)

sureshh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 23, 2024

Thanks @Ben for your response.

The solution you provided is actually targetting sharing bitbucket pipelines configurations, however I was actually looking for YAML anchors way where I should be able to reuse YAML configuration across multiple repositories.

https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/ describes solution which works only in single file.

Do you know if thats even possible? Please advise. Thanks.

Note: As per my so far research seems like its not even possible to share such common config across multiple yaml files as YAML considers each file separately.

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 24, 2024

Hi @sureshh 

You can only have one YML file per branch and the name will need to be bitbucket-pipelines.yml.

You can share the YML configuration across multiple repositories, we have further documentation related to this below (note: This is a Premium feature) -

Once you've configured shared pipelines, here's what an example of YAML anchors would look like - here we're using an anchor to refer to a step named build and then referring to it as "develop" later on - export true will export and then it can be referred to later on in the other repository through calling it:

Exported Pipeline (Repo name: Export_Pipeline_Test)

export: true

definitions:
 steps:
  - step: &build
     name: Build test
     script:
      - echo "Hello world!"

 pipelines:
  develop:
  - stage:
      name: Build and Deploy to Development
      deployment: DEV
      steps:
        - step:
            <<: *build

Import Pipeline

pipelines:
  branches:
   develop:
    import: export_pipeline_test:develop:develop

 Hope this helps.

Cheers!

- Ben (Bitbucket Cloud Support)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events