Steps to reproduce:
Create CircleCI configuration that deploys YAML anchors:
- image: ruby:2.4
name: Save SHA to file
command: echo $CIRCLE_SHA1 > .circle-sha
name: Connect to database
command: ~/cloud_sql_proxy -credential_file=/root/client-secret.json -instances="app-staging:europe-west1:app-stag" -dir=/cloudsql
Validate YAML with
circleci config validate .circleci/config.yml
Validation fails with:
Error: Error parsing config file: yaml: line 16: did not find expected key
I ran into the exact same issue the other day. I assumed I was doing something wrong.
Thanks for putting this here, we will look into it.
Yes, in terms of workflows and
gcloud for instance, we have a lot of redundant code that I’d love to DRY up. Having standard YAML anchor behaviour would allow that.
Thanks for the heads up!
You’re using the YAML merge syntax with a list. As far as I’m aware, you can only use it for maps.
Looks related to this feature request: https://discuss.circleci.com/t/allow-bundling-several-steps-e-g-by-supporting-nested-steps/
If you read about concatenating yaml lists on stackoverflow there are various solutions people have come up with for adding in something like a custom merge directive so that you could do:
- run: command1
- run: command2
- run: command3
Which would then parse to:
I assume we have no control over the intermediary steps between grabbing the config.yml and reading it, but I guess we could write the config in our own format then use a script to create the final yml file, but doesn’t sound ideal.
Have you found any solution for this?
What would be really useful here is if CircleCI called a shell hook in the
.circleci folder, maybe called
config.sh. That would have a chance to rewrite the
config.yml file in any way it wishes (e.g. using templates) and then Circle could then proceed.
Frankly, this would really help me right now. I have probably 10 different microservices in the same repo, and the only difference between their build processes is the Working Directory (and therefor my Persist to Workspace).
If you’re just looking to DRY up your config, just use a scripting language to build the YAML config file, and don’t edit the file directly. Just run your script to regen the config, and commit what it builds to Git.
I’d generally avoid building a build file. Building for a build should not be done.
Each to their own, I suppose, and I’m certainly happy to hear why you think that.
The thing with hosted CI is that unless one has trivial requirements, occasionally one has to workaround something, and that’s (usually) a minor price to pay for not having to maintain one’s own CI facility.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.