How to get build ENV variables set based on Deploy environments?
During the build step, there is a need to pass ENVIRONMENT variables, for the build as well. On branch develop, deploy environment is dev, for the build step we need to pass PROJECT_ENV as development, on branch release, deploy environment is staging, for the build step, PROJECT_ENV should be set as staging.
setting the PROJECT_ENV is not sufficient
global variables dont show up in build step and if environment is not declared. Is there an obvious solution I am missing here with dynamic variables?
I can only think of introducing CI Triggers to invoke a pipeline with a variable name
when you create the environment variable in your project settings you can give that variable a scope which is the environment that the variable should be defined in. For your develop branch, if there isnât and environment defined in .gitlab-ci.yml you can set the variable to be scoped in All environments.
I setup for âdevâ environment, but the variable is not picking it up since there is no way to link develop with dev unless I setup that mapping via âenvironmentâ field.
If you make your environment variable for dev scoped to âallâ environments, then it will be picked up by any environment except your named environments.