Allow jobs to cast an environment variable type at runtime
Problem to solve
.gitlab-ci.yml ultimately consumes all environment variables, yet it has no control over their "type" (currently file/env_var).
Good illustration why this mismatch is problematic would be a migration from existing group-level AWS_CONFIG_FILE
env var, which was used as a prime motivation for this feature in https://gitlab.com/gitlab-org/gitlab-ce/issues/46806.
One can't just change AWS_CONFIG_FILE
env var type from env_var
to file
on a project level, because it would just break all pipelines as they treat that var as a config file content, not a path with a given content.
If it was possible for a pipeline job to determine itself whether it wants to use the variable as a normal
or file
type, more flexibility could be gained here.
Intended users
Whoever is maintaing .gitlab-ci.yml for their projects
Proposal
As it is .gitlab-ci.yml which consumes env vars, "type" of variable should be declared there, not on a project/group level.
Notion of "type" in initial tickets drove whole UX thinking into a wrong direction. file
/env_var
are not types, these are format, or presentation modes, or views of the same content not a "type". As such it is a consumer of these vars should be declaring how exactly it want them to be presented to it: as an env var or as a file.
Not an exact proposal, but something like following should be allowed in .gitlab-ci.yml:
variables:
AWS_CONFIG_FILE:
mode: file
ANOTHER_VAR:
mode: env_var
value: "XYZ"