6

I'm using GitLab CI/CD and I have a pipeline that includes a job from a separate configuration file, which has seemed to work ok. It looks like this:

.gitlab-ci.yml:

stages:
  - triggers
  - build
  - test
  - deploy

trigger_infra:
  stage: triggers
  trigger:
    include: src/infra/.gitlab-ci.yml
  rules:
    - changes:
      - src/infra/lib/spa-stack.ts

src/infra/.gitlab-ci.yml:

deploy_spa:
  stage: deploy
  script:
    - cd src/spa

However, I recently ran into the following scenario:

  1. Pushed code up that changed the spa-stack.ts file; build triggered and passed
  2. Create merge request to master; build triggered and got an error!
  3. Merged to master; build triggered and passed

The error message for the merge build was "downstream pipeline cannot be created, Pipeline will not run for the selected trigger. The rules configuration prevented any jobs from being added to the pipeline."

What am I missing here? The downstream job has no rules configurations on it AFAIK, so I feel like it should always just run, no questions asked.

1 Answer 1

14

By default, jobs do not run on merge request pipelines. That's why you have a problem with the downstream pipelines on merge requests.

To ensure the downstream pipeline works in both branch pipelines and pipelines for merge requests, you need to add rules: to the job (the rule itself doesn't matter much, but the mere presence of the rules: key will cause it to trigger on merge request pipelines).

deploy_spa:
  stage: deploy
  script:
    - cd src/spa
  rules:
    - when: on_success
Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.