npk
npk

Reputation: 1810

Gitlab-ci - Pipeline status is 'succeeded' in overview

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:

Overview - Normal case

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:

Overview - Change in scripts

The jobs are as follows:

Job - Merge request Job - Always running

backend_only_mr is flagged as detached, if it helps.

Upvotes: 0

Views: 570

Answers (1)

olearycrew
olearycrew

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:

  1. Specify only: merge_requests on every job you want to count against "can we merge this"?
  2. The new global workflow setting lets you say "I want all of my jobs to run on a merge request pipeline".
  3. There are a number of issues around how consolidated pipelines should work going foward. Would love your feedback in thos.

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

Related Questions