Make $DRUPAL_CORE and $PHP_VERSION available in all jobs

Migrated issue

Reported by: jonathan1055

Related to !201 (merged)

Problem/Motivation

In #3441816: All variants run the same Drupal version when the pipeline is triggered via web two new "internal" variables PHP_VERSION and DRUPAL_CORE were created to ensure that the correct core version and php_version are used in the composer variant jobs.

PHP_VERSION is defined at the top-level job variables, as PHP_VERSION: $_TARGET_PHP, then adjusted in composer max php and the previous/next major (but not minor as that uses the value in 'current'. It is also adjusted in the other variant jobs that need it.

DRUPAL_CORE is defined in .composer-base as DRUPAL_CORE: $_TARGET_CORE, then redefined in Composer previous/next major/minor. It is also used in expand_composer.php

This is working OK, but there are two places for potential improvement:

  1. $PHP_VERSION is always defined for every subsequent job, but $DRUPAL_CORE is only defined for the composer jobs. $DRUPAL_CORE is not strictly needed in other jobs from the point of view of which core version is being used, because that is already determined by which version of needs: composer ... is used. But the variable can be useful in custom scripts, for patching, doing conditionals in after_script, etc.
  2. In the variant jobs for PHPUNIT, PHPSTAN and NIGHTWATCH, the value of $PHP_VERSION is also set to match the same value specified in the Composer variant. This duplication has the potential for being wrong if the variable is changed in one but not the other.

Proposed resolution

Investiagate ways to make both variables available in all jobs and have the correct values.

Assignee Loading
Time tracking Loading