Trigger other pipelines

Ability to split automation across multiple pipeline

Trigger tokens

Trigger pipelines using trigger tokens

Fire and forget

Multi-project pipelines

Launch pipeline in separate project

Use the trigger keyword

Parent-child pipelines

Load stages and jobs from a file using include

Hands-On: Trigger tokens

  1. Create a new project (anywhere!)
  2. Add trigger/.gitlab-ci.yml to root of new project
  3. Optionally, jump to next demo/slide
  4. Go to Settings > CI/CD and unfold Pipeline triggers
  5. Create a trigger and copy curl snippet
  6. Go back to previous project
  7. Switch to branch main
  8. Add new stage and job called trigger
  9. Add curl snippet in script block
  10. Store TOKEN as unprotected but masked CI variable
  11. Fill in REF_NAME with branch name (main)

See new .gitlab-ci.yml:

git checkout origin/160_gitlab_ci/110_triggers/curl -- '*'


Visibility of trigger tokens

Users sees only their own tokens

Tokens of other users are hidden

Branch protection can prevent triggers

Trigger owner must be able to either…

Hands-On: Multi-project pipelines

  1. Replace script with trigger keyword
  2. Specify project and branch:

         project: foo/bar
         branch: main
  3. Check pipeline

Hands-On: Parent-child pipelines

  1. Add parent-child/child.yml to root of first project
  2. Replace project and branch under trigger with include

         include: child.yml

Child pipeline can be made from multiple files

include supports local for files in the same repository

Use project/ref/file for files in other repositories

Included file can also be generated before job start

Pro tip: Variable inheritence

Downstream pipelines inherit some variables

Job variables are passed on unless:

    variables: false

Predefined variables must be redefined as job variables:

    my_var: ${CI_COMMIT_REF_NAME}

Do not redefined masked variables - they will not be masked