gitlab-ci.yml - parameterize job:when or expose $job_JOBNAME_result for better flow control
job:when currently allows four options:
- on_success
- on_failure
- always
- manual
What I'm trying to achieve is something among these lines:
run this job only when job1 and job2 are successful
Better explained by the gitlab-ci.yml example itself:
stages:
- build
- deploy
lint:
stage: build
allow_failure: true
script:
- make lint
test:
stage: build
script:
- make test
compile:
stage: build
script:
- make
assets:
stage: build
script:
- make assets
deploy:
stage: deploy
when:
on_success:
- compile
- assets
script:
- cap deploy
We could achieve the same result by adding allow_failure: true to the test job but then it would mark all builds as successful/green. What we're really looking to do is to mark the build as failed but yet execute some jobs based on the result of particular jobs. It's not possible today - on_success and on_failure run based on the result of the stage, not job.
An alternative approach that doesn't involve extending the current syntax is to expose some extra variables, e.g. $job_JOBNAME_result, in this case, $job_lint_result, $job_test_result, $job_compile_result and $job_assets_result. With this, I can simply exit 0 inside deploy based on results of specific jobs.
Your thoughts on this syntax, @ayufan and @tmaczukin?