I am rewriting all the
rules of my job, trying to modularize and reuse them by means of YAML anchors. Since this is quite a big rework I’d like to test the rules by running the jobs locally before pushing everything. But it seems that
gitlab-runner exec executes a job regardless of the
rules: for example, I have an
if rule which checks the value of a variable, and the job is executed even if the variable is not defined at all. For example, this job:
- if: $NONEXISTING == "hello"
- echo deploy-env-cvmfs-centos7
is actually executed when I run
gitlab-runner exec shell deploy-env-cvmfs-centos7, since I see the echo output. So how can I check if my rules (far more complicated than the oversimplified example above) are correctly implemented without having to push to my main repo?
gitlab-runner exec does not parse and understand the
rules configuration which leads to executing a job. This part is done on the GitLab server side, which puts the job into a queue for execution, from which the runner service fetches the job tasks from.
That said, the pipeline editor in the UI provides a
Validate tab that allows to simulate the
rules behavior which can be helpful. Another use case: You can also check the full configuration, i.e. when using job templates with rules, if they are inherited into the job scope.
That’s a really nice feature, I didn’t know it. Experimenting with it I came to the conclusion that it cannot handle multiple YAML files, right? If I put some
include statements for local files in my
.gitlab-ci.yml then it seems that these files are not included, even if I pushed them to the repo.
Edit: well it seems that actually you can include other files, but only if they are already committed, and anyway I cannot edit them on the fly to quickly check the modifications. I hope these features will be added since without these the pipeline editor is hardly usable with complex CI setups.
Edit2: Validation seems to not work with multiple files, even those that are found and shown in the side panel, and complains about missing included file.