Skip to content

Pass environment variables when triggering a pipeline with $CI_JOB_TOKEN

Description

When triggering a new pipeline using $CI_JOB_TOKEN (used by Multi-Project Pipelines), it is not possible to pass environment variables in the same way they can be passed when using Personal Access Tokens. This is due to a different implementation of the trigger on the backend side, that lacks the ability to store variables that are passed in the call.

Proposal

Support passing variables when triggering a pipeline using $CI_JOB_TOKEN, in the same way we can pass variables to regular triggers.

Use cases

In order to deploy documentation with pages, I'd like to have the documentation building jobs and deployment in a dedicated project, not containing the source code or the the documentation itself. Pushes to the source-code project then trigger the pipeline in this doc-building project, but the latter would need to know exactly which branch/commit it is supposed to build the documentation for.

Example

Variables can be passed in the following way:

curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=master https://gitlab.example.com/api/v4/projects/9/trigger/pipeline
Edited by Fabio Busatto