'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 1:[1]

You can play with rules, only and except keywords in triggered ci file, for example add this to jobs that you want to trigger:

except:
  variables:
    - $CI_PROJECT_ID != {{ your main project id }}

And for jobs you don't want trigger this:

except:
  variables:
    - $CI_PROJECT_ID == {{ your main project id }}

Or if you want use rules, add this to jobs you want to run in main project:

rules:
  - if: $CI_PROJECT_ID == {{ your main project id }}
    when: never
  - when: always

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Makariy