YAML linting fails on some MR generated pipelines
Summary
When using a set of if/when rules in a skipped and anchored job (anchored via an &
character) and passing the anchored job to alternate job (that has a needs
value) using <<: *anchored_job
, merge request generated pipelines fail with a YAML invalid
linting error.
When a normal commit is pushed and the pipeline is triggered, the pipeline runs successfully and is working as intended. This only occurs if the pipeline is created via an MR. A screenshot of the error seen on MR generated pipelines can be seen below.
Steps to reproduce
-
Create a new project for testing
-
Add the following
.gitlab-ci.yml
file to the project
stages:
- build
- test
.manual_on_branch: &manual_on_branch
rules:
- if: '$CI_COMMIT_TAG'
when: never
- if: '$CI_COMMIT_REF_NAME !~ /^(master)|(staging)|(release)/'
when: manual
- if: '$CI_COMMIT_REF_NAME =~ /^master/ && $CI_COMMIT_REF_NAME =~ /^staging/ && $CI_COMMIT_REF_NAME =~ /^release/'
when: on_success
job1:
stage: build
image: node:latest
script:
- echo ""
job2:
stage: test
image: node:latest
script:
- echo ""
needs: [ 'job1' ]
<<: *manual_on_branch
-
Create a test branch to trigger the successful pipeline
-
Create a new MR using the test branch to trigger the failed (
YAML invalid
) pipeline
Example Project
https://gitlab.com/calebw/rules_testing
What is the current bug behavior?
YAML invalid error is thrown on pipelines generated via Merge Requests with this CI configuration.
What is the expected correct behavior?
YAML linting should pass as it does on commit generated pipelines with this CI configuration.
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
Possible fixes
(If you can, link to the line of code that might be responsible for the problem)