Search code examples
gitlabgitlab-ci

How do I trigger a specific job that belongs to a pipeline from another project in GitLab?


I'm aware that is possible to trigger another pipeline from another project by adding the below commands in a gitlab-ci file:

bridge:
  stage: stage_name_here
  trigger: 
    project: path_to_another_project
    branch: branch_name
    strategy: depend

The problem is that the config above will trigger all jobs, and I want to trigger only 2 jobs within the pipeline.

Any idea on how to trigger only those 2 specific jobs?


Solution

  • Instead of defining a variable that needs to be passed by the upstream pipeline that is triggering the downstream pipeline, I simply added the lines below in the jobs that I don't want to run in the downstream pipeline when triggered by another job:

    except:
        refs:
          - pipelines
    

    source: https://docs.gitlab.com/ee/ci/triggers/index.html#configure-cicd-jobs-to-run-in-triggered-pipelines