Write variant environment variables to build.env
In this discussion on GTD we found that the environment variables which are automatically passed to all jobs in the pipeline are only those defined in the include files and at the top-level in .gitlab-ci.yml. If a variable value is modifed in a Composer variant job then this modified value is not propagated to the other jobs using that Composer variant.
This makes those variables inconsistent and therefore unusable in subsequent jobs. In particular, _LENIENT_ALLOW_LIST is not available for use in the PHPUnit job, to make dependent modules compatible for installing.
The variables that are set in the Composer variants in the templates are:
DRUPAL_CORE
PHP_VERSION
IGNORE_PROJECT_DRUPAL_CORE_VERSION
PHP_IMAGE_VARIANT
_NODE_VERSION
MINIMUM_STABILITY_OVERRIDE
Of these, DRUPAL_CORE, PHP_VERSION and PHP_IMAGE_VARIANT are already being written to build.env.
Proposed solution
In addition to _LENIENT_ALLOW_LIST, also write IGNORE_PROJECT_DRUPAL_CORE_VERSION, _NODE_VERSION and MINIMUM_STABILITY_OVERRIDE to the build.env file in the Composer job.