Validation differs from local with "when" syntax
heydonovan opened this issue · 4 comments
Minimal .gitlab-ci.yml illustrating the issue
---
x:
script:
- echo "this does nothing!"
stage: .pre
when: never
Expected behavior
An error to trigger with gitlab-ci-local --preview
or with gitlab-ci-local x
. Instead it runs locally but not on GitLab
> $ gitlab-ci-local x
x starting shell (.pre)
x $ echo "this does nothing!"
x > this does nothing!
x finished in 13 ms
Host information
macOS 14.6.1
gitlab-ci-local 4.53.0
Additional context
The "Pipeline editor" gives the following error:
This GitLab CI configuration is invalid: jobs:x when should be one of: on_success, on_failure, always, manual, delayed
Validating your input
{
stages: [ '.pre', 'build', 'test', 'deploy', '.post' ],
x: {
script: [ 'echo "this does nothing!"' ],
stage: '.pre',
when: 'never'
}
}
with the following schema https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/editor/schema/ci.json,
using https://www.jsonschemavalidator.net/ shows that it's fine.
i am thinking we either
- add custom assertions to match this behavior
- fix the json schema (which can be tricky)
So Gitlab's json schema does allow when:never
, but their editor shows the error, but it really shouldn't be an error?
their editor shows the error, but it really shouldn't be an error?
I think it still should be an error, since the specs clearly stated that when:never
is only allowed in Can only be used in a [rules](https://docs.gitlab.com/ee/ci/yaml/#rules) section or workflow: rules.
it's just that in this case, i guess gitlab is not handling this validation via json schema validation but rather some logic somewhere else
Yeah, its already merged.