Do not create deployment records for `skipped` deploy jobs
Context
We want to make sure that deployment records are only created for deploy jobs that are ready to run. This means that deploy jobs that are still at the created or at the skipped state should not have deployment records.
Create Deployments for processed (ready-to-run)... (#391291 - closed) ensures that deploy jobs with status=created do not yet have a deployment record by creating the deployment record only when the job is about to be processed.
Ensuring that a skipped job does not have a deployment record is a little more complicated since a job is mark as skipped during processing.
In this issue, we want to make sure that deployment records are not created for skipped jobs.
Illustration
Given this GitLab CI configuration:
stages: [other, stages, here, stage-4, stage-5]
# jobs in other stages here
canary:
stage: stage-4
environment:
name: canary
action: start
script: exit 0
when: manual
production-a:
stage: stage-5
environment:
name: production-a
action: start
script: exit 0
when: manual
production-b:
stage: stage-5
environment:
name: production-b
action: start
script: exit 0
when: manual
needs: [canary]
- Once the pipeline has reached the
canaryjob, we expect deployment records to be created forcanary. - We also expect a deployment record to be created for
production-abecause thecanaryjob is set asallow_failure: trueby default, meaning thatproduction-awill be run regardless of whethercanarysucceeds or not. - We do not expect a deployment record to be immediately created for
production-bbecause it is set asneeds: [canary], meaning that it will not run ifcanaryfails. We only expect a deployment record to be created oncecanarysucceeds.
Expectations 1 & 2 are met: deployment records are created for canary and production-a
Expectation 3 is not met: a deployment record is still immediately created for production-b. We need to change this so that a deployment record is created only when canary succeeds.
Step-by-step status changes + deployment records creation during processing
Expected behavior
| processing | states & deployment records |
|---|---|
pipeline reaches canary job |
canary (manual with deployment) => production-a (manual with deployment) => production-b (skipped without deployment) |
IF canary job succeeds |
canary (success with deployment) => production-a (manual with deployment) => production-b (manual with deployment) |
IF canary job fails |
canary (failed with deployment) => production-a (manual with deployment) => production-b (skipped without deployment) |
Current behavior
| processing | states & deployment records |
|---|---|
pipeline reaches canary job |
canary (manual with deployment) => production-a (manual with deployment) => production-b (skipped with deployment) |
IF canary job succeeds |
canary (success with deployment) => production-a (manual with deployment) => production-b (manual with deployment) |
IF canary job fails |
canary (failed with deployment) => production-a (manual with deployment) => production-b (skipped with deployment) |
Proposal
TBA