From 2f41f005b2932ce13d0c9bb4d747996fc36f3e18 Mon Sep 17 00:00:00 2001 From: Jonathan Smith <20701-jonathan1055@users.noreply.drupalcode.org> Date: Fri, 2 May 2025 08:21:56 +0000 Subject: [PATCH] Issue #3518751 by jonathan1055, fjgarlin: Move calculation of gitlab templates version out of *show-ci-variables --- includes/include.drupalci.main-d7.yml | 13 ++++++++++--- includes/include.drupalci.main.yml | 13 ++++++++++--- ...version.php => get-gitlab-templates-version.php} | 3 ++- 3 files changed, 22 insertions(+), 7 deletions(-) rename scripts/{extract-version.php => get-gitlab-templates-version.php} (95%) diff --git a/includes/include.drupalci.main-d7.yml b/includes/include.drupalci.main-d7.yml index 53362eb6..5226e3d5 100644 --- a/includes/include.drupalci.main-d7.yml +++ b/includes/include.drupalci.main-d7.yml @@ -79,11 +79,17 @@ export DRUPAL_PROJECT_FOLDER=$CI_PROJECT_DIR/$_WEB_ROOT/$DRUPAL_PROJECTS_PATH/$CI_PROJECT_NAME echo "DRUPAL_PROJECT_FOLDER=$DRUPAL_PROJECT_FOLDER" >> build.env +# Determine the Gitlab Templates version and store for later use. +.templates-version: &templates-version + - | + echo "Executing curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/scripts/get-gitlab-templates-version.php" + curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/scripts/get-gitlab-templates-version.php + export GITLAB_TEMPLATES_VERSION=$(php get-gitlab-templates-version.php $_CURL_TEMPLATES_REF) && rm get-gitlab-templates-version.php + echo "GITLAB_TEMPLATES_VERSION=$GITLAB_TEMPLATES_VERSION" >> build.env + # Display the Gitlab Templates version, the Composer version and some useful CI variables. .show-ci-variables: &show-ci-variables - - echo "Executing curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/scripts/extract-version.php" - - curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/scripts/extract-version.php - - php extract-version.php $_CURL_TEMPLATES_REF && rm extract-version.php + - echo "Gitlab Templates version $GITLAB_TEMPLATES_VERSION" - composer --version - | printf "CI_PIPELINE_SOURCE = %s\n" $CI_PIPELINE_SOURCE && @@ -298,6 +304,7 @@ stages: - cd $CI_PROJECT_DIR && pwd - *create-environment-variables - *calculate-gitlab-ref + - *templates-version - *show-ci-variables - *show-environment-variables - printf "$DIVIDER\n* If you have defined _TARGET_PHP or _TARGET_DB_VERSION on your project, please rename them to be _TARGET_D7_PHP or _TARGET_D7_DB_VERSION.$DIVIDER\n" diff --git a/includes/include.drupalci.main.yml b/includes/include.drupalci.main.yml index 7876647a..5f8bc061 100644 --- a/includes/include.drupalci.main.yml +++ b/includes/include.drupalci.main.yml @@ -108,11 +108,17 @@ export DRUPAL_PROJECT_FOLDER=$CI_PROJECT_DIR/$_WEB_ROOT/$DRUPAL_PROJECTS_PATH/$CI_PROJECT_NAME echo "DRUPAL_PROJECT_FOLDER=$DRUPAL_PROJECT_FOLDER" >> build.env +# Determine the Gitlab Templates version and store for later use. +.templates-version: &templates-version + - | + echo "Executing curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/scripts/get-gitlab-templates-version.php" + curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/scripts/get-gitlab-templates-version.php + export GITLAB_TEMPLATES_VERSION=$(php get-gitlab-templates-version.php $_CURL_TEMPLATES_REF) && rm get-gitlab-templates-version.php + echo "GITLAB_TEMPLATES_VERSION=$GITLAB_TEMPLATES_VERSION" >> build.env + # Display the Gitlab Templates version, the Composer version and some useful CI variables. .show-ci-variables: &show-ci-variables - - echo "Executing curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/scripts/extract-version.php" - - curl -OL https://git.drupalcode.org/$_CURL_TEMPLATES_REPO/-/raw/$_CURL_TEMPLATES_REF/scripts/extract-version.php - - php extract-version.php $_CURL_TEMPLATES_REF && rm extract-version.php + - echo "Gitlab Templates version $GITLAB_TEMPLATES_VERSION" - composer --version - | printf "CI_PIPELINE_SOURCE = %s\n" $CI_PIPELINE_SOURCE && @@ -431,6 +437,7 @@ stages: - cd $CI_PROJECT_DIR && pwd - *create-environment-variables - *calculate-gitlab-ref + - *templates-version - *show-ci-variables - *show-environment-variables - *add-composer-drupal-lenient diff --git a/scripts/extract-version.php b/scripts/get-gitlab-templates-version.php similarity index 95% rename from scripts/extract-version.php rename to scripts/get-gitlab-templates-version.php index 1c445b70..0dd0057d 100644 --- a/scripts/extract-version.php +++ b/scripts/get-gitlab-templates-version.php @@ -67,5 +67,6 @@ if (isset($tags[$current_ref])) { $version = $found_tag ? $found_tag : "$current_ref (branch)"; -echo "GitLab Templates version: $version\n"; +// This output is stored in the GITLAB_TEMPLATES_VERSION environment variable. +echo $version; exit; -- GitLab