According to CI's lint, this yml is not valid:
pages:
stage: deploy
image: python:3.5
script:
- echo "foo: $VAR" > site.yml
- cat ~/.python-gitlab.cfg
artifacts:
paths:
- _build
only:
- master
error:
jobs:pages:script config should be a string or an array of strings
If I remove the colon on the echo
line, it works.
What I want to do is to create some configuration files on the fly, to comply to existing tools, using private variables, like echo "url: $CI_PROJECT_URL" > site.yml
to produce
url: "https://gitlab.com/group/project"
But I can't do this because the yaml is said invalid, and I don't find workarounds. Or I must write code around my tools to pass command line arguments instead of reading config files. Still, this colon stuff seems a bug.
It should work if you wrap the whole line within quotes like this:
- 'echo "foo: $VAR" > site.yml'
Gitlab's CI lint marks it as correct syntax.
See here for more info.
Single quotes around the whole line, as depicted by @Jawad, works:
- 'echo "foo: $VAR" > site.yml'
But if your command contains other single quotes, I find it easiest to use the pipe
Block Scaler Style: |
- |
echo "I want to echo the key"
echo 'foo: $VAR' > site.yml
More documentation on Block Scaler Styles can be found here: http://www.yaml.org/spec/1.2/spec.html#id2760844
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With