Skip to content

Dynamic pipelines doesn't work when `only:` field is set

Summary

So, we're trying to use the new feature "dynamic pipelines" to deduplicate/autogenerate our .gitlab-ci.yml, which otherwise become kinda unmaintanable. Unfortunately we found, it refuses to work when there's a only: [merge_requests] field is set. This is a deal-breaker, because clearly we can't drop that field, otherwise the code will run in situations different from merge_requests.

Workarounds are welcome.

Steps to reproduce

Assuming you have a project with CI already set:

  1. Create a branch testcase, and on that branch:

    • Replace .gitlab-ci.yml content with:

      stages:
        - build
        - test
      
      build_merge_request:
        stage: build
        only: [merge_requests]
        artifacts:
          paths: [output.yml]
        script:
          - cp input.yml output.yml
      
      run_tests:
        stage: test
        only: [merge_requests]
        needs:
          - build_merge_request
        trigger:
          include:
            - artifact: output.yml
              job: build_merge_request
    • Add input.yml with content:

      foo:
        stage: test
        script:
          - echo hello from generated test!
  2. Create a merge request from testcase to master.

Example Project

I used the gitlab dynamic-pipelines showcase project to reproduce issue. To see the problem see this merge request

What is the current bug behavior?

The stage "test" doesn't pass. It shows an unclickable red cross icon, and if you hover over it, it shows a tooltip:

run_tests - failed - (downstream pipeline can not be created, No stages/jobs for this pipeline.)

What is the expected correct behavior?

The test passes.

Output of checks

This bug happens on GitLab.com

Edited by Hi-Angel