Skip to content

Variables of a scheduled pipeline not returned through API call

Summary

GET /projects/:id/pipelines/:pipeline_id/variables does not return any result when the pipeline is scheduled

Steps to reproduce

  1. Add a pipeline in the pipeline scheduler with some extra variables. For example:
workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
      when: always
    - if: '$CI_PIPELINE_SOURCE == "web"'
      when: always
    - when: never

stages:
  - build

build:
  stage: build
  tags:
    - linux
  script:
    - echo $var1
    - echo $var2
  1. Wait for the pipeline to finish
  2. Try to get the variables $var1 and $var2 through the API

Example Project

https://gitlab.com/phibid/bug_project_api_var/-/pipelines/292455985

What is the current bug behavior?

I am unable to get the variables, the result returned by the API is empty:

$ curl -s -H "PRIVATE-TOKEN: xxx" https://gitlab.com/api/v4/projects/26182394/pipelines/292455985/variables
[]

What is the expected correct behavior?

The same pipeline run by hand: https://gitlab.com/phibid/bug_project_api_var/-/pipelines/292448470

return the following result:

$ curl -s -H "PRIVATE-TOKEN: xxx" https://gitlab.com/api/v4/projects/26182394/pipelines/292448470/variables
[{"variable_type":"env_var","key":"var1","value":"toto"},{"variable_type":"env_var","key":"var2","value":"titi"}]

This bug happens on GitLab.com