You will usually see two things in YAML
- Sequences — in other programming languages, this is commonly referred as arrays, lists, ...:
- apple
- banana
- pear
- Mappings — in other programming languages, this is commonly referred as objects, hashes, dictionaries, associative arrays, ...:
question: how do I foobar?
body: Can you help?
tag: yaml
So if you want to store a mapping of mapping you would do:
pier1:
boat: yes
in_activity: yes
comments: needs some painting in 2023
## The mapping above this comment refers to the pier1,
## as it is indented one level below the key `pier1`
pier2:
boat: no
in_activity: no
comments: currently inactive, needs urgent repair
## The mapping above this comment refers to the pier2,
## as it is indented one level below the key `pier2`
While, if you store a list in a mapping, you could go without the indent, indeed:
fruits:
- apple
- banana
- pear
Is strictly equal to
fruits:
- apple
- banana
- pear
But, if you are trying to indent the first step of your pipeline only, like so:
pipelines:
default:
- step:
deployment: production
You end up with an valid YAML, but, a YAML that does not have the same meaning anymore.
When your original yaml means: I do have a default pipeline with a list of actions, the first action being a step that consists of a deployment to production.
The resulting incorrectly indented YAML means: I do have a default pipeline with a list of actions, the first action having two properties, the first property being an empty step, and the second property is that it is a deployment to production.
So, here, really, the deplyement key that was a property of the step mapping became a property of the first element of the list default!
To indent all this as you would like, you will have to go:
pipelines:
default:
- step:
deployment: production
## ^-- This property is now further indented too
So, you end up with the YAML:
image: atlassian/default-image:2
pipelines:
default:
- step:
deployment: production
script:
- git submodule update --recursive --init
- zip -r $FILENAME . -x bitbucket-pipelines.yml *.git*
- pipe: atlassian/bitbucket-upload-file:0.1.6
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
FILENAME: $FILENAME