Reputation: 1810
My .gitlab-ci.yml
file is as follows:
always_on:
before_script:
- echo 'before_script'
script: echo 'script done'
always_fail:
before_script:
- echo 'before_script'
script: fail_now
backend_only_mr:
only:
refs:
- merge_requests
- master
changes:
- scripts/**/*
before_script:
- echo 'before_script'
script: echo 'script done'
As you can see, there is always_fail
job which always fails. If I have no changes in scripts
directory, this works fine and Merge-request overview shows the pipeline is failed:
When I have made a change in the scripts
directory, the job fails, as expected, but the overview shows that the job has succeeded because backend_only_mr
is succeeded:
The jobs are as follows:
backend_only_mr
is flagged as detached
, if it helps.
Upvotes: 0
Views: 570
Reputation: 406
That is expected behavior currently, as the two pipelines run for the commit and merge request separately. Then the merge request pipeline passes "after" the commit one fails, and GitLab sees it as passed.
There are a couple of options to deal with this:
only: merge_requests
on every job you want to count against "can we merge this"?workflow
setting lets you say "I want all of my jobs to run on a merge request pipeline".You also can read more about how we're solving for this with rules:
vs. only/except:
here: https://docs.gitlab.com/ee/ci/yaml/#key-details-when-using-rules.
Upvotes: 1