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.
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)
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.