Variable contains content of file instead of file path

Summary

When assigning a variable of type "file" to another variable, that new variable contains the content of the file instead of the filepath as described in https://docs.gitlab.com/ce/ci/variables/#custom-environment-variables-of-type-file

Steps to reproduce

  1. Create variable of type file in Gitlab CI UI
  2. In a build job, assign this variable to another variable in the .gitlab-ci.yml file

Example Project

https://gitlab.com/caspre24/file-variable-bug
https://gitlab.com/caspre24/file-variable-bug/-/jobs/919452004

What is the current bug behavior?

The variable defined in the .gitlab-ci.yml file contains the file content.

What is the expected correct behavior?

The variable defined in the .gitlab-ci.yml file contains the file path.

Relevant logs and/or screenshots

.gitlab-ci.yml

bug:
  image: alpine
  tags:
    - docker
  variables:
    ENV_FILE: $ENV_FILE_VAR
  script:
    - echo $ENV_FILE_VAR
    - cat $ENV_FILE_VAR
    - echo $ENV_FILE
    - cat $ENV_FILE

Build log:

Executing "step_script" stage of the job script
00:00
$ echo $ENV_FILE_VAR
/builds/caspre24/file-variable-bug.tmp/ENV_FILE_VAR
$ cat $ENV_FILE_VAR
This is the files content
It may span several lines$ echo $ENV_FILE
This is the files content It may span several lines
$ cat $ENV_FILE
cat: can't open 'This': No such file or directory
cat: can't open 'is': No such file or directory
cat: can't open 'the': No such file or directory
cat: can't open 'files': No such file or directory
cat: can't open 'content': No such file or directory
cat: can't open 'It': No such file or directory
cat: can't open 'may': No such file or directory
cat: can't open 'span': No such file or directory
cat: can't open 'several': No such file or directory
cat: can't open 'lines': No such file or directory
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes