Attempt to setup auto-deploy on CI/CD

Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
Louis Vallat 2020-10-29 15:52:50 +01:00
parent 9a57de9ad2
commit 31c5d54635

View File

@ -2,7 +2,14 @@
# This is the Gradle build system for JVM applications # This is the Gradle build system for JVM applications
# https://gradle.org/ # https://gradle.org/
# https://github.com/gradle/gradle # 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 # Disable the Gradle daemon for Continuous Integration servers as correctness
# is usually a priority over speed in CI environments. Using a fresh # is usually a priority over speed in CI environments. Using a fresh
@ -10,11 +17,17 @@ image: gradle:jdk15
# isolated from any previous builds. # isolated from any previous builds.
variables: variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false" 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: before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle - export GRADLE_USER_HOME=`pwd`/.gradle
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
build: build:
image: gradle:jdk15
stage: build stage: build
script: gradle --build-cache assemble script: gradle --build-cache assemble
cache: cache:
@ -24,6 +37,7 @@ build:
- build - build
- .gradle - .gradle
test: test:
stage: test stage: test
script: gradle check script: gradle check
@ -31,5 +45,18 @@ test:
key: "$CI_COMMIT_REF_NAME" key: "$CI_COMMIT_REF_NAME"
policy: pull policy: pull
paths: paths:
- build - build/libs/*.jar
- .gradle - .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