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 :)
gitlab-ci. yml file is a YAML file where you configure specific instructions for GitLab CI/CD. In this file, you define: The structure and order of jobs that the runner should execute.
In GitLab, CI/CD variables can be defined by going to Settings » CI/CD » Variables, or by simply defining them in the . gitlab-ci. yml file. Variables are useful for configuring third-party services for different environments, such as testing , staging , production , etc.
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.
No, it is not possible to have dynamic job names in GitLab CI.
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