Instead of interpreting rev|staging
, a far more natural way of implementing that would be using a flow style sequence as a key:
pipelines:
branches:
[rev, staging]:
- step:
script:
- echo 'step'
That would alleviates the need for quoting and for making sure spaces, or an extra (trailing) comma, make no semantic difference. Depending on the library that bitbucket uses to process this, the above might parse correctly, but not load (e.g. PyYAML cannot handle the above, but ruamel.yaml
). I have not been able to verify if this preferable way actually works in bitbucket.
There are two ways that do work, one using the familiar YAML functionality of anchors and aliases to provide repeated (complex) data structures only once:
pipelines:
branches:
rev: &sharedsteps
- step:
script:
- echo 'step'
staging: *sharedsteps
The other possibility is, as others have indicated, to use some a non-standard, bitbucket specific, interpretation of scalar keys with embedded comma's. I have not found clear documentation on this, but the glob patterns seem applicable, so you can use {rev,staging}
as a key.
What is ugly about this is that {
is the flow-style sequence indicator in YAML, so that scalar needs to be quoted:
pipelines:
branches:
"{rev,staging}":
- step:
script:
- echo 'step'
The above was updated using the corrected step syntax that BlueM provided