Skip to content

Backend: CI prefill variables do not show when included via CI_COMMIT_REF_NAME

Example 1

#438593 (closed)

Example 2

Given a project who's path is "emoji-ops/gitlab-ci", and the following templates/workflows/default/template.yml file:

spec:
  inputs:
    PIPELINE_TYPE:
      default: ""
---
variables:                                                                                     
  PIPELINE_NAME: "Unnamed pipeline"                                                            
  PIPELINE_TYPE:                                                                               
    value: "$[[ inputs.PIPELINE_TYPE ]]"                                                       
    description: "Prefix to prepend to pipeline name."                                         

And the following .gitlab-ci.yml

include:
  - component: "gitlab.com/emoji-ops/gitlab-ci/templates/workflows/default@jle-initial-draft"  

dummy:
  stage: build
  image: alpine
  script:
    - /bin/true

As expected, PIPELINE_TYPE is shown. Also, as expected, PIPELINE_NAME is hidden and will need a value + description to be visible.

image


But, if the .gitlab-ci.yml contains predefined variables, not even group nor project variables, then the variables will never be shown.

The edited .gitlab-ci.yml file:

include:
  - component: "gitlab.com/emoji-ops/gitlab-ci/templates/workflows/default@${CI_COMMIT_REF_NAME}"  

dummy:
  stage: build
  image: alpine
  script:
    - /bin/true

And the result is:

image

The result is the same no matter where the envvar is placed.


Why is this important?

  • For one, the CI catalog project will most probably reference itself with component path ${CI_SERVER_HOST}/${CI_PROJECT_PATH}/templates/example@${CI_COMMIT_REF_NAME}
  • When forked/mirror on a different instance (my use case), and in the event you can't place the projet in the exact same project path as on gitlab.com, it's easiest to create an instance variable such as CI_CATALOG_PATH and use it as: ${CI_CATALOG_PATH}/templates/example@master

I consider this a bug, and the fix would be to take into account the predefined, instance, group and projet variables when displaying the editable pipeline variables.

Edited by Furkan Ayhan