Skip to content

Variables of schedules are not returned by pipeline variables endpoint

The pipeline variables endpoint does not return the variables which were created for schedules.

Can be tested via the following .gitlab-ci.yml

stages:
   - build

variables:
  GREETING:
    value: "Hello"
    description: "Some greeting which the job will display"

dummy_job:
   stage: build
   script:
     - echo "$GREETING dear user"

If you now run a pipeline of a project containing the above yaml via -/pipelines/new, you'll get the value of the GREETING variable:

➜  ~ curl --header "PRIVATE-TOKEN: $GITLAB_API_TOKEN" "https://gitlab.com/api/v4/projects/$PROJECT_ID/pipelines/$PIPELINE_ID/variables" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    62  100    62    0     0     73      0 --:--:-- --:--:-- --:--:--    74
[
  {
    "variable_type": "env_var",
    "key": "GREETING",
    "value": "Hello"
  }
]

Now create a schedule and set some variables for the schedule: Bildschirmfoto_2022-04-28_um_11.28.14

After that, press the "Play" button of the created schedule. My expectation was that if this schedule creates a pipeline, the entered variables for this schedule are returned by the pipeline variables endpoint. But actually no variables are returned:

➜  ~ curl --header "PRIVATE-TOKEN: $GITLAB_API_TOKEN" "https://gitlab.com/api/v4/projects/$PROJECT_ID/pipelines/$PIPELINE_ID/variables" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100     2  100     2    0     0      2      0  0:00:01 --:--:--  0:00:01     2
[]