Sign in or sign up before continuing. Don't have an account yet? Register now to get started.
Register now

Backend: CI/CD variable of type "file" do not resolve to file names when referenced within global variable declarations

Summary

CI/CD variables of type "file" do not resolve to file names when referenced within global variable declarations

Steps to reproduce

Define a CI/CD variable of type "file" in the project, e. g. FILE V1 SOME_VALUE.

In .gitlab-ci.yml use the variable in two places: Within a global variable's definition, and within a script.

variables:
  V2: "$V1"

build:
  script:
    - 'echo $V1'
    - 'echo $V2'

Example Project

https://gitlab.com/mkarg/gitlabbugresolvefilevariable

What is the current bug behavior?

While echo $V1 correctly prints the file name, echo $V2 incorrectly prints the file content.

What is the expected correct behavior?

echo $V1 and echo $V2 should both print the file name but never the file content.

Relevant logs and/or screenshots

$ echo $V1
/builds/mkarg/gitlabbugresolvefilevariable.tmp/V1
$ echo $V2

SOME_VALUE

Proposal

When V1 is type file and i would like to pass it over to V2 we will define it in the following manner

V2:
  value: "$V1"
  type: file

This will ensure that the content of V2 is the file path and not the file content

This suggestion could be a solution for the issue in #29407 (closed)

Edited Apr 06, 2022 by Mark Nuzzo
Assignee Loading
Time tracking Loading