Skip to content

Can't create the type of YAML list I want #185

Answered by TomWright
paradajz asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @paradaj, sorry for the delayed response. I must have missed this when it was first posted.

This is how you can achieve that:

echo "" |
dasel put string -p yaml 'rules.[].if' 'if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME && $CI_OPEN_MERGE_REQUESTS' |
dasel put string -p yaml -m "rules.[0].when" "never" |
dasel put string -p yaml -m "rules.[].when" "always"

The output is:

rules:
- if: 'if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME && $CI_OPEN_MERGE_REQUESTS'
  when: never
- when: always

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@paradajz
Comment options

Answer selected by TomWright
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants