Still trying to get auto-deploy to work

Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
Louis Vallat 2020-10-29 17:26:13 +01:00
parent 3864269786
commit 7e15f2f633

View File

@ -5,7 +5,7 @@ services:
stages: stages:
- build - build
- test - test
- deploy - 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
@ -16,10 +16,12 @@ variables:
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled # Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
DOCKER_HOST: tcp://docker:2376 DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs" DOCKER_TLS_CERTDIR: "/certs"
CONTAINER_LATEST_IMAGE: $CI_REGISTRY_IMAGE:latest CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_RELEASE_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 image: gradle:jdk15
@ -44,19 +46,12 @@ test:
- build/libs/*.jar - build/libs/*.jar
- .gradle - .gradle
release-image:
package: stage: release
stage: deploy
image: $CI_REGISTRY/group/project/docker:19.03.12
services:
- name: $CI_REGISTRY/group/project/docker:19.03.12-dind
alias: docker
variables:
IMAGE_LATEST_TAG: $CI_REGISTRY_IMAGE:latest
IMAGE_COMMIT_REF_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
script: script:
- docker login -u $CI_REGISTRY_IMAGE -p $CI_BUILD_TOKEN $CI_REGISTRY - docker info
- docker build -t $IMAGE_LATEST_TAG -t $IMAGE_COMMIT_REF_TAG . - docker pull $CONTAINER_TEST_IMAGE
- docker push $IMAGE_LATEST_TAG $IMAGE_COMMIT_REF_TAG - docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
only: only:
- master - master