CI Lint API: allow to validate scheduled pipelines and pipelines with variables
Content
CI Lint API supports an endpoint POST /projects/:id/ci/lint
link which accepts a ref
and allows to validate if the gitlab YAML file passed as content
will allow creating a valid pipeline. With include_jobs: true
it will also return an array of jobs that will be created in such pipeline.
However this only works for default pipeline. It doesn't support pipelines with variables or scheduled pipelines.
Use case:
In our case, we have a scheduled pipeline that is only supposed to have a short list of well-defined jobs (job1
, job2
, job3
), compared to regular pipelines that have tens of jobs.
It regularly happens that someone adds a new job and forgets to add except: [schedules]
or equivalent if:rules
and then this job mistakenly shows up in scheduled pipelines.
Solution
I'd like as part of my CI to POST /projects/:id/ci/lint
with a payload like {content: "MYGITLABYAML", ref: prod, include_jobs: true, scheduled: yes, vars: {MY_VAR: 123}}
, then read .jobs
from the output and if there are more jobs than I expect, I fail the CI.