Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

Variables set on the Run new pipeline page never reach the GitLab child pipeline

Your error

A variable entered on the Run new pipeline page prints an empty value in the child pipeline's jobs1 more line it can show

Fix it fast

Most common cause, 1 of 3

Pipeline variables are not forwarded unless you ask for it

Turn on pipeline_variables in the trigger job.

Fix
trigger-child:
  trigger:
    include: .child-pipeline.yml
    forward:
      pipeline_variables: true
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

GitLab does not pass pipeline variables (set on the Run new pipeline page, in a schedule or through the API) to a child pipeline by default; only YAML variables go down. Add forward: pipeline_variables: true to the trigger job, repeat it on nested triggers, and set values on the whole pipeline, not a manual trigger job. Applies to GitLab 19.6.

  • Applies to GitLab 19.6 (GitLab.com and Self-Managed), GitLab 18.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Print the variable in one parent job and in one child job of the same pipeline run. Present in the parent but empty in the child means the trigger job is not forwarding it.

Run this first
# parent .gitlab-ci.yml
show-in-parent:
  script: echo "MYVAR in parent is '$MYVAR'"
# .child-pipeline.yml
show-in-child:
  script: echo "MYVAR in child is '$MYVAR'"

Then find the line you see in this list and open its fix:

  1. 1Pipeline variables are not forwarded unless you ask for itVariables written in the YAML (top-level variables or the trigger job's variables) reach the child; values typed in the UI, a schedule or an API call do not
  2. 2The value is needed in a grandchild pipelineThe child pipeline sees the variable, but a pipeline the child triggers does not
  3. 3The variable was meant to be typed on a manual trigger jobThe trigger job uses when: manual, and the plan was to enter the values when someone presses its play button

What does the error look like?

  • A variable entered on the Run new pipeline page prints an empty value in the child pipeline's jobs
  • The same variable works in the parent pipeline's jobs

Cause 1 of 3

Pipeline variables are not forwarded unless you ask for it

You seeVariables written in the YAML (top-level variables or the trigger job's variables) reach the child; values typed in the UI, a schedule or an API call do not

Check

The empty child value comes from the default forwarding rule. The CI/CD YAML reference lists two switches under trigger:forward: yaml_variables, true by default, and pipeline_variables, false by default. Values from manual runs, pipeline schedules and dotenv reports of jobs in needs count as pipeline variables, so they stay in the parent.

Check
grep -n -A6 'trigger:' .gitlab-ci.yml

Fix

Turn on pipeline_variables in the trigger job. Forwarded values have high precedence, so a variable of the same name defined in the child is usually overwritten by the parent's value.

Fix
trigger-child:
  trigger:
    include: .child-pipeline.yml
    forward:
      pipeline_variables: true

Verify

Run the pipeline again from the UI with MYVAR set. The child job prints the value.

Verify
grep -n -B2 -A2 'pipeline_variables: true' .gitlab-ci.yml

Confirmed by docs.gitlab.com

Did this fix it?

Cause 2 of 3

The value is needed in a grandchild pipeline

You seeThe child pipeline sees the variable, but a pipeline the child triggers does not

Check

Forwarding works one level at a time. GitLab's reference says forwarded variables are not forwarded again in nested downstream pipelines unless the nested trigger job also uses trigger:forward. Parent and child pipelines can nest at most two levels of child pipelines.

Check
grep -rn -A6 'trigger:' .gitlab-ci.yml .child-pipeline.yml

Fix

Add the same forward block to the trigger job inside the child pipeline's file.

Fix
# .child-pipeline.yml
trigger-grandchild:
  trigger:
    include: .grandchild-pipeline.yml
    forward:
      pipeline_variables: true

Verify

A job in the grandchild pipeline prints the value set on the Run new pipeline page.

Verify
grep -c 'pipeline_variables: true' .gitlab-ci.yml .child-pipeline.yml

Confirmed by docs.gitlab.com

Did this fix it?

Cause 3 of 3

The variable was meant to be typed on a manual trigger job

You seeThe trigger job uses when: manual, and the plan was to enter the values when someone presses its play button

Check

A manual job normally lets you enter variables before it runs, but trigger jobs are an exception. The reference states that you cannot manually specify CI/CD variables before running a manual trigger job, so nothing typed at that point can reach the child.

Check
grep -n -B4 'when: manual' .gitlab-ci.yml

Fix

Set the value when you start the whole pipeline on the Run new pipeline page, and forward pipeline variables from the manual trigger job. For values that only steer configuration, GitLab recommends pipeline inputs (spec:inputs with trigger:include:inputs) over variables.

Fix
trigger-child:
  when: manual
  trigger:
    include: .child-pipeline.yml
    forward:
      pipeline_variables: true

Verify

Start a new pipeline with the variable set, press play on the trigger job, and the child job prints the value.

Verify
grep -n -A6 'trigger-child:' .gitlab-ci.yml

Confirmed by docs.gitlab.com

Did this fix it?

How do I stop it coming back?

  • Add forward: pipeline_variables: true to every trigger job that depends on values chosen at run time, and leave a comment saying which variables it carries.
  • Move run-time choices to spec:inputs, which GitLab recommends over pipeline variables from version 17.7 on.
  • Keep one debug job in each child pipeline file that echoes the variables it expects, so a missing value shows up in the first job log.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.