How to properly block merge request pipeline on bot commit


We have pipelines that runs terraform code:

  • when a MR is opened, we have 3 jobs that runs: terraform validate, terraform format, terraform plan
  • the format step auto format the code and push a new commit to the source branch
  • the plan adds the generated plan in the discussion (and clear the older ones)
  • when the MR is merged the plan is applied
  • we enable the option that a pipeline must succeed to allow merge request to be merged.

What is expected:

The format step push the diff commit without triggering a new pipeline, and we can merge the request.

What happens:

The format step push the diff commit without triggering a new pipeline. However:

  • the MR is blocked with " Checking pipeline status." and the wheel spinning indefinitely
  • the “Merge” button is grayed out with the message: Merge blocked: all merge request dependencies must be merged or closed.

Which version of gitlab:

GitLab Community Edition [14.8.4]

Pipeline configuration:

Each job in the merge request pipeline had:

  rules:     - if: '$CI_COMMIT_TITLE !~ /^auto format$/ && $CI_PIPELINE_SOURCE == "merge_request_event"'

The jobs that runs when merged have:

  rules:     - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'

We tried to use “git push -o ci.skip” but it created a skipped pipeline and the merge request pipeline is also triggered.

We tried to change the title test to $GITLAB_USER_LOGIN == "git-automation", and finally we tried:

    - if: $GITLAB_USER_LOGIN == "git-automation"
      when: never

    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'

I guess that something is waiting for a new pipeline consecutive to the push that is not created. What is the way to go ?


Hi @jbe-dw

do you have Pipelines must succeed option enabled for that project?


Yes we have it enabled.

This is known limitation that you can read on official docs.

If Pipelines must succeed is enabled, there must be a pipeline present. Skipped pipelines would cause such issue. There are 2 possible solutions I can think of:

  • also check Skipped pipelines are considered successful if that works for you.


re-structure your pipeline so that validate and format jobs are running on normal push and plan is running when bot does the auto format commit.

Thank you for the feedback. I though it wouldn’t because a pipeline is launch once we open the merge request.

We could also put the autoformat in a hook and revert to the period where we just check (without an automatic change).

I’ll try the other option and tell you if it works.

Unfortunately, “Skipped pipelines” option does not work.

That might be a bug in my opinion, might be worth raising an issue in Gitlab issue tracker if that’s intentional or not.