From 31c5d546358e6ecf993f01cc0e66ac935823ea2a Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Thu, 29 Oct 2020 15:52:50 +0100 Subject: [PATCH] Attempt to setup auto-deploy on CI/CD Signed-off-by: Louis Vallat --- .gitlab-ci.yml | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fe4b303..e0a5ff3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,14 @@ # This is the Gradle build system for JVM applications # https://gradle.org/ # https://github.com/gradle/gradle -image: gradle:jdk15 +image: docker:latest +services: + - docker:dind + +stages: + - build + - test + - release # Disable the Gradle daemon for Continuous Integration servers as correctness # is usually a priority over speed in CI environments. Using a fresh @@ -10,11 +17,17 @@ image: gradle:jdk15 # isolated from any previous builds. variables: GRADLE_OPTS: "-Dorg.gradle.daemon=false" + # Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled + DOCKER_HOST: tcp://docker:2376 + DOCKER_TLS_CERTDIR: "/certs" + CONTAINER_LATEST_IMAGE: $CI_REGISTRY_IMAGE:latest before_script: - export GRADLE_USER_HOME=`pwd`/.gradle + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY build: + image: gradle:jdk15 stage: build script: gradle --build-cache assemble cache: @@ -24,6 +37,7 @@ build: - build - .gradle + test: stage: test script: gradle check @@ -31,5 +45,18 @@ test: key: "$CI_COMMIT_REF_NAME" policy: pull paths: - - build + - build/libs/*.jar - .gradle + + +package: + stage: release + variables: + IMAGE_LATEST_TAG: $CI_REGISTRY_IMAGE:latest + IMAGE_COMMIT_REF_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + script: + - docker login -u $CI_REGISTRY_IMAGE -p $CI_BUILD_TOKEN $CI_REGISTRY + - docker build -t $IMAGE_LATEST_TAG -t $IMAGE_COMMIT_REF_TAG . + - docker push $IMAGE_LATEST_TAG $IMAGE_COMMIT_REF_TAG + only: + - master \ No newline at end of file