Export environment variables from pre_build_script or pre_clone_script

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem to solve

Compute and set custom environment variables for use in all jobs executed by GitLab runners. These values are necessarily dynamic and specific to each project. They can not just be set in the environment section of the config.toml file.

The pre_build_script and pre_clone_script would seem to be the perfect place to compute and set these values via a centrally-maintained script. Unfortunately, values exported from here are not currently available to the underlying job after these scripts exit.

Related functionality (included for completeness) would be the ability to set values in the post_build_script because those could then be passed to and used by the after_script.

Proposal

Provide a method for environment variables to be computed via a centrally-maintained script and passed down the computing pipeline for subsequent processes to use. The pre_build_script pre_clone_script and post_build_script would seem to be a good place to compute and set these values.

What does success look like, and how can we measure that?

Variables will be computed and passed to subsequent processes and those processes will be able to use them as part of CI processing.

Links / references

/cc: @jlenny @danielgruesso

Edited by 🤖 GitLab Bot 🤖