Backend: Prevent When keyword from being defined as an array
Summary
When using then When
keyword as an array, it will leave the job in a skipped state, giving the impression that it is supposed to work when in reality, When
keywords should never be allowed to be used as arrays.
Steps to reproduce
- Add the following pipeline definition in any CI/CD enabled project
Click to expand `gitlab-ci.yml`
image: alpine
test:
stage: test
script: exit 0
when-is-a-string:
stage: deploy
script: exit 0
when: manual
when-is-an-array:
stage: deploy
script: exit 0
when:
- manual
When
keyword as an array. When defining as a string, it can be clicked in the UI to trigger the job.
- Visit the created pipeline
- Await completion of "test" stage job
- Notice that when "test" stage job completes,
when-is-an-array
can't be run at all andwhen-is-a-string
can be.
Example project
https://gitlab.com/marknuzzo/labs/-/pipelines/424594910
What is the current bug behavior?
The job called when-is-an-array
is shown, giving the impression that it could work like when-is-a-string
, but is not clickable.
What is the expected correct behavior?
We should not allow a When
keyword to be an array at all as it should only be a string.
Workarounds
Users need to manually change When
keyword to a string but it should not be allowed to be an array initially.
Output of checks
This bug happens on GitLab.com