sferencik
sferencik

Reputation: 3249

Merge request dropped from merge train with "No stages / jobs for this pipeline."

When I click Start merge train on a merge request (MR), GitLab adds the following to the MR's system notes:

@sferencik started a merge train just now

Great. However, seconds later the following is added to the system notes:

@sferencik removed this merge request from the merge train because No stages / jobs for this pipeline. just now

[emphasis mine]

The list of pipelines doesn't have a new entry: the merge train didn't even get as far as starting one.

The GitLab documentation touches on this. This GitLab issue also talks about this, though in a different context.

What am I doing wrong? I have cut down my .gitlab-ci.yml to the bare minimum, leaving only one stage with one job, which is not conditional. It beats me why GitLab, having performed the speculative merge, should create a pipeline with "no stages / jobs."

This is not a build issue: by the time I click Start merge train, a pipeline has succeeded on my feature branch (the one I want to merge).

Also, if I switch off pipelines for merge results, my MRs have a Merge button instead of Start merge train and it works just fine.

This started happening with our upgrade from GitLab 12.0 to 12.1.

Upvotes: 9

Views: 5038

Answers (2)

sferencik
sferencik

Reputation: 3249

OK, so this is due to my error: the "pipelines for merge requests" feature requires that each job is explicitly marked with

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

My jobs didn't have this explicit condition. (In fact, as I describe above, I took care to remove all conditions from my jobs.)

Thus, when I hit Start merge train, a new pipeline is (or would be) instantiated with only those jobs that have the above condition. In my case that's no jobs at all, hence the error message: No stages / jobs for this pipeline..

Possible solutions are:

  • switch off the pre-merge builds (Settings > General > Merge requests > uncheck Merge pipelines will try to validate the post-merge result prior to merging)
  • modify your .gitlab-ci.yml, tagging each job with the rules:if condition (see here for other rules:if conditions if you want to run the pipeline for MRs as well as for e.g. branches)

Upvotes: 8

rgrebski
rgrebski

Reputation: 2584

This way you have duplicated jobs in Merge Request builds and Merge Train builds. You can use following config to build either only merge requests or only merge trains.

Merge requests:

merge-request-only:
  stage: build
  script: echo test
  only:
    refs:
      - merge_requests
    variables:
      - $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result"

Merge trains only:

merge-train-only-test:
  stage: build
  script: echo test
  only:
    refs:
      - merge_requests
    variables:
      - $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"

Upvotes: 1

Related Questions