moviequotebot/.gitlab-ci.yml

77 lines
1.7 KiB
YAML
Raw Normal View History

image: docker:latest
services:
- docker:dind
stages:
- build
- test
- package
- release
2020-10-25 10:33:56 +01:00
# Disable the Gradle daemon for Continuous Integration servers as correctness
# is usually a priority over speed in CI environments. Using a fresh
# runtime for each build is more reliable since the runtime is completely
# 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_BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
2020-10-25 10:33:56 +01:00
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
build:
image: gradle:jdk15
2020-10-25 10:33:56 +01:00
stage: build
script: gradle --build-cache compileJava
2020-10-25 10:33:56 +01:00
cache:
key: "$CI_COMMIT_REF_NAME"
policy: push
paths:
- build
- .gradle
2020-10-25 10:33:56 +01:00
test:
image: gradle:jdk15
2020-10-25 10:33:56 +01:00
stage: test
script: gradle --build-cache check
2020-10-25 10:33:56 +01:00
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- build
- .gradle
package:
image: gradle:jdk15
stage: package
script: gradle --build-cache assemble
cache:
key: "$CI_COMMIT_REF_NAME"
policy: push
paths:
- build
2020-10-25 10:33:56 +01:00
- .gradle
artifacts:
paths:
- build/libs/*.jar
release:
stage: release
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . -t $CONTAINER_BRANCH_IMAGE
- docker push $CONTAINER_BRANCH_IMAGE
release-master:
stage: release
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . -t $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
only:
- master