From cde9483feda31c360d712abef24e70266c9566b9 Mon Sep 17 00:00:00 2001 From: Fascinated Date: Wed, 8 Mar 2023 14:07:23 +0000 Subject: [PATCH] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f3eb2eb..1de3f49 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ image: openjdk:17-jdk-slim stages: + - prepare - build - release @@ -9,6 +10,18 @@ before_script: # - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug - export GRADLE_USER_HOME=`pwd`/.gradle +prepare_job: + stage: prepare # This stage must run before the release stage + rules: + - if: $CI_COMMIT_TAG + when: never # Do not run this job when a tag is created manually + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch + script: + - echo "TAG=v$(cat VERSION)" >> variables.env # and append to the variables.env file + artifacts: + reports: + dotenv: variables.env # Use artifacts:reports:dotenv to expose the variables to other jobs + cache: paths: - .gradle/wrapper @@ -37,9 +50,9 @@ release: when: never # Do not run this job when a tag is created manually - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch script: - - echo "running release for $CI_COMMIT_TAG" + - echo "running release for $TAG" release: - name: 'Release $CI_COMMIT_TAG' + name: 'Release $TAG' description: 'Created using the release-cli $EXTRA_DESCRIPTION' # $EXTRA_DESCRIPTION and the $TAG - tag_name: '$CI_COMMIT_TAG' # variables must be defined elsewhere + tag_name: '$TAG' # variables must be defined elsewhere ref: '$CI_COMMIT_SHA' # in the pipeline. For example, in the \ No newline at end of file