Problem to solve
Trying to use multiline strings in a CI/CD component, e.g. alike this template:
# templates/foo_job/template.yml
spec:
inputs:
bar:
default: "bar"
---
.foo-job:
script:
- &query_r_deps >-
Rscript .gitlab/query_r_deps.R
"$[[ inputs.bar ]]"
The main .gitlab-ci.yml
is in another project, and looks like:
# .gitlab-ci.yml
include:
- component: $CI_SERVER_FQDN/domain/project/foo_job
actual_foo_job:
script:
- !reference [ .foo_job, script ]
This fails to run as the argument is not passed to Rscript as it should be.
If I look at Full configuration
in the Pipeline Editor
with the substituted values for each of the inputs, I see:
...
script:
- |-
Rscript .gitlab/query_r_deps.R
"bar"
..
The argument "bar"
is now its own command because the type of block quote has been changed.
Versions
-
Self-managed
-
GitLab.com SaaS
-
Self-hosted Runners
-
GitLab Enterprise Edition 17.3.0-pre 417d660cb1a
I would like to avoid bash-specific fixes, and also to understand why the Full configuration
seems to convert all >
blocks to |
blocks, even though this can cause fundamental changes in what is executed.
I was not able to solve my problem with https://docs.gitlab.com/ee/ci/yaml/script.html#split-long-commands. If there are other resources or explanations, thanks in advance.