diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2d7d16e8ba8db99c80a445fd1558da77a26151f9..7bb1bcf98a32857e534552aad44264d921939484 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,26 +1,4 @@ -stages: - - .pre - - build - - test - - post - - security - -.default: - variables: - DEFAULT_TAG: "1.2.0-SNAPSHOT" - before_script: - - | - if [ "$CI_COMMIT_REF_NAME" = "main" ] && [ -n "$CI_COMMIT_TAG" ]; then - export APP_VERSION=$CI_COMMIT_TAG - elif [ "$CI_COMMIT_REF_NAME" = "develop" ]; then - export APP_VERSION="develop" - else - export APP_VERSION=$DEFAULT_TAG - fi - rules: - - if: $CI_COMMIT_REF_NAME == "main" - - if: $CI_COMMIT_REF_NAME == "develop" - - if: $CI_COMMIT_REF_NAME == "12-create-a-pipeline-to-build-and-publish-the-docker-image-in-gitlab-registry" +include: ci-templates/build.yml maven_build: extends: .maven_build \ No newline at end of file diff --git a/ci-templates/default.yml b/ci-templates/default.yml new file mode 100644 index 0000000000000000000000000000000000000000..99595b5fe158139a89c02d0b616cc4c383d681b2 --- /dev/null +++ b/ci-templates/default.yml @@ -0,0 +1,23 @@ +stages: + - .pre + - build + - test + - post + - security + +.default: + variables: + DEFAULT_TAG: "1.2.0-SNAPSHOT" + before_script: + - | + if [ "$CI_COMMIT_REF_NAME" = "main" ] && [ -n "$CI_COMMIT_TAG" ]; then + export APP_VERSION=$CI_COMMIT_TAG + elif [ "$CI_COMMIT_REF_NAME" = "develop" ]; then + export APP_VERSION="develop" + else + export APP_VERSION=$DEFAULT_TAG + fi + rules: + - if: $CI_COMMIT_REF_NAME == "main" + - if: $CI_COMMIT_REF_NAME == "develop" + - if: $CI_COMMIT_REF_NAME == "12-create-a-pipeline-to-build-and-publish-the-docker-image-in-gitlab-registry" \ No newline at end of file