We make heavy use of YAML anchors in our bitbucket-pipelines.yml files. We have a simple step named build-test which builds the bundle and runs unit tests. We want a separate deployment value set depending on the branch. With the following configuration
definitions:
steps:
- step: &build-test
size: 2x
deployment: test # I want to be able to override this
max-time: 15
name: Build
caches:
- node
script:
- echo "do something"
pipelines:
branches:
master:
- step:
<<: *build-test
deployment: production
develop:
- step:
<<: *build-test
deployment: test
I get the following error
There is an error in your bitbucket-pipelines.yml at [pipelines > branches > develop > 1 > step > script > 0]. Missing or empty command string. Each item in this list should either be a single command string or a map defining a pipe invocation.
Im using this as a reference: https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/
This error is forcing me to define multiple steps which do the same thing.
Hi Cosimo,
The issue you're seeing happens because YAML anchors and aliases in Bitbucket Pipelines can't override individual child nodes within a section. Instead, they replace the entire section. In your case, when you attempt to override the deployment
value, it causes the script
section to be overridden/removed.
To resolve this:
script
section remains intact while overriding the deployment
value.Please try the following config and let me know how it goes:
definitions:
steps:
- step: &build-test
size: 2x
max-time: 15
name: Build
caches:
- node
script:
- echo "do something"
pipelines:
branches:
master:
- step:
<<: *build-test
deployment: production
develop:
- step:
<<: *build-test
deployment: test
Cheers!
- Ben (Bitbucket Cloud Support)
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.