首页 > 解决方案 > 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.

标签: gitlabgitlab-ci

解决方案


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

only:
- merge_requests

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 "only: merge_requests" condition (read here about how to build your condition so your jobs are not limited to merge requests)

推荐阅读