I have to migrate from jenkins to gitlab and I would like to be able to use dynamic job names in order to have some information directly in the pipeline summary without having to click on each job etc.... in jenkins we can immediately see the parameters passed to our job and this is not the case in gitlab-ci.
My test runner being on a windows I tried to define the yml as follows:
job_%myParam%:
stage: build
script:
- set>varList.txt
artifacts:
paths:
- varList.txt
When I start my job with %myParam%=true
, the variable is not interpreted in the job name and so it takes the name of job_%myParam% instead of expected "job_true".
Is that even possible?
thks :)
As of gitlab 12.9, this can be done using trigger
and child pipelines — although a little involved:
Quoting the example from the gitlab doc:
generate-config:
stage: build
script: generate-ci-config > generated-config.yml
artifacts:
paths:
- generated-config.yml
child-pipeline:
stage: test
trigger:
include:
- artifact: generated-config.yml
job: generate-config
In your case, you would put the definition of job_%myParam%
in job.yml.in
, then have the script generate-ci-config
be e.g. sed "s/%myParam%/$PARAM/g" job.yml.in
.
This is probably a bit much for just changing the names of course, and there will be a cost associated to the additional stage; but it does answer the question, and may be useful to do more, like start with different versions of the parameter in the same pipeline.