Trigger a specific stage from a GitLab pipeline with another GitLab pipeline

I need to specify the stage instead of triggering the whole thing. This is how it's currently configured.

stage: bridge
trigger:
   project: user/project2
   branch: master
   strategy: depend

Upvotes: 2

Views: 3762

Answers (1)

danielnelz
danielnelz

Reputation: 5164

You can specify variables in the parent pipeline which you can check in the child pipeline and specify the job creation via rules. In the below example only job1 is run as only the variable $FOO is set in the parent pipeline.

You parent pipeline:

test:
  stage: test
  variables:
    FOO: bar
  trigger:
    project: user/project2
    branch: master
    strategy: depend

Your child pipeline can look like this:

stages:
 - job1
 - job2

job1:
  stage: job1
  script:
    - echo "job1"
  rules:
    - if: '$FOO'

job2:
  stage: job2
  script: 
    - echo "job2"
  rules:
    - if: '$BAR'

Upvotes: 3

Related Questions