- Issue created by @jonathan1055
- Merge request !349#3518751 Move extract-version.php to separate ref → (Merged) created by jonathan1055
- 🇬🇧United Kingdom jonathan1055
Here are two "before" examples of the problem. First running
.show-ci-variables
in a composer after_script fails, because we are trying to curl the file without the_CURL_TEMPLATES_REPO
andREF
being set.Second, adding
.show-ci-variables
in another job after_script works, but is confusing and wasteful because we are downloading and executing the script again - 🇬🇧United Kingdom jonathan1055
Downstream pipelines for D10 and D7 show the Gitlab Templates version as required.
Here's a test, where the reference is using in cspell after_script
cspell: after_script: - !reference [ .show-ci-variables ] - echo "=== GITLAB_TEMPLATES_VERSION=$GITLAB_TEMPLATES_VERSION" - echo "=== VERSION_USING_PUTENV=$VERSION_USING_PUTENV" - echo "=== GITLAB_TEMPLATES_VERSION2=$GITLAB_TEMPLATES_VERSION2" - echo "=== VERSION_USING_PUTENV2=$VERSION_USING_PUTENV2" - source build.env - echo "GITLAB_TEMPLATES_VERSION=$GITLAB_TEMPLATES_VERSION" - echo "GITLAB_TEMPLATES_VERSION2=$GITLAB_TEMPLATES_VERSION2"
The value is displayed, but annoyingly it also shows the quotes, as they are written to
build.env
. But when an extrasource build.env
is added the variables do not have the quotes. This does not really matter, as the default display in Composer is clean. It is just unusual that the values read from build.env a second time appear to behave better than the initial read.
https://git.drupalcode.org/issue/scheduler-3445052/-/jobs/5085925 - 🇪🇸Spain fjgarlin
I made a couple of comments in the MR, one of them around the quotes, in case it makes a difference.
- 🇬🇧United Kingdom jonathan1055
I've tidied up the try-out code, renamed the script as requested, and removed the quotes. All runs ok in the latest downstream pipeline (the previous failure was before I rebased, and phpunit failed due to the quotes around project type, that was fixed yestterday)
Here's a test where cspell after_script calls
!reference [ .show-ci-variables ]
and it works cleanly
https://git.drupalcode.org/issue/scheduler-3445052/-/pipelines/486624This is ready for review.
- 🇪🇸Spain fjgarlin
This looks good to me. Thanks for addressing the feedback. RTBC.
-
fjgarlin →
committed 2f41f005 on main authored by
jonathan1055 →
Issue #3518751 by jonathan1055, fjgarlin: Move calculation of gitlab...
-
fjgarlin →
committed 2f41f005 on main authored by
jonathan1055 →
- 🇬🇧United Kingdom jonathan1055
Just for the record, the
build.env
file is read automatically and the variables with spaces and without quotes are loaded correctly in all script sections of the subsequent jobs that follow a composer job. The only place where the variables created incomposer: script:
are automatically available is in a customcomposer: after_script:
and this is wheresource build.env
used to work, but now fails due to having a variable with spaces in. But the same can be achieved using the slightly more complicated versionIFS=$'\n' && export $(<build.env) && unset IFS
An example of this is https://git.drupalcode.org/issue/scheduler-3445052/-/jobs/5132987#L1122