Search code examples
gitlabgitlab-cigitlab-ci-runnergitlab-ci.yml

Gitlab CI: trigger job giving error - unknown key: strategy


I have a requirement where I have to run multi project pipeline. I have been successfully able to do that. But as soon as I add stragey: depend the pipeline fails with the error - "unknown key:strategy". I have checked the document here - https://docs.gitlab.com/ee/ci/pipelines/downstream_pipelines.html?tab=Multi-project+pipeline#mirror-the-status-of-a-downstream-pipeline-in-the-trigger-job and it says that we can use strategy:depend but somehow I'm getting the errorenter image description here Below is the code

trigger_job:
  stage: trigger
  trigger:
    project: path-to-projectB
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  strategy: depend

Solution

  • The error is raised because you're not nesting strategy under trigger but instead using it as a key. The docs show an example.

    Your config should look like this instead:

    trigger_job:
      stage: trigger
      trigger:
        project: path-to-projectB
        strategy: depend
      rules:
        - if: $CI_PIPELINE_SOURCE == "merge_request_event"