2020-10-29 15:52:50 +01:00
|
|
|
image: docker:latest
|
|
|
|
services:
|
|
|
|
- docker:dind
|
|
|
|
|
|
|
|
stages:
|
|
|
|
- build
|
|
|
|
- test
|
2020-10-29 21:05:16 +01:00
|
|
|
- package
|
2020-10-29 17:26:13 +01:00
|
|
|
- release
|
2020-11-10 20:42:15 +01:00
|
|
|
- deploy
|
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"
|
2020-10-29 15:52:50 +01:00
|
|
|
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
|
|
|
|
DOCKER_HOST: tcp://docker:2376
|
|
|
|
DOCKER_TLS_CERTDIR: "/certs"
|
2020-10-29 19:29:41 +01:00
|
|
|
CONTAINER_BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
2020-10-29 17:26:13 +01:00
|
|
|
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
|
2020-10-25 10:33:56 +01:00
|
|
|
|
|
|
|
before_script:
|
|
|
|
- export GRADLE_USER_HOME=`pwd`/.gradle
|
|
|
|
|
|
|
|
build:
|
2020-10-29 15:52:50 +01:00
|
|
|
image: gradle:jdk15
|
2020-10-25 10:33:56 +01:00
|
|
|
stage: build
|
2020-10-29 21:22:31 +01:00
|
|
|
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-29 15:52:50 +01:00
|
|
|
|
2020-10-25 10:33:56 +01:00
|
|
|
test:
|
2020-10-29 16:04:48 +01:00
|
|
|
image: gradle:jdk15
|
2020-10-25 10:33:56 +01:00
|
|
|
stage: test
|
2020-10-29 21:05:16 +01:00
|
|
|
script: gradle --build-cache check
|
2020-10-25 10:33:56 +01:00
|
|
|
cache:
|
|
|
|
key: "$CI_COMMIT_REF_NAME"
|
|
|
|
policy: pull
|
|
|
|
paths:
|
2020-10-29 21:05:16 +01:00
|
|
|
- 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
|
2020-10-29 21:05:16 +01:00
|
|
|
artifacts:
|
|
|
|
paths:
|
2020-11-09 11:55:35 +01:00
|
|
|
- build/libs/moviesquotebot.jar
|
2020-10-29 15:52:50 +01:00
|
|
|
|
2020-10-29 21:05:16 +01:00
|
|
|
release:
|
2020-10-29 19:29:41 +01:00
|
|
|
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
|
|
|
|
|
2020-10-29 21:05:16 +01:00
|
|
|
release-master:
|
2020-10-29 17:26:13 +01:00
|
|
|
stage: release
|
2020-10-29 15:52:50 +01:00
|
|
|
script:
|
2020-10-29 19:12:45 +01:00
|
|
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
2020-10-29 21:05:16 +01:00
|
|
|
- docker build . -t $CONTAINER_RELEASE_IMAGE
|
|
|
|
- docker push $CONTAINER_RELEASE_IMAGE
|
2020-10-29 15:52:50 +01:00
|
|
|
only:
|
2020-11-10 20:42:15 +01:00
|
|
|
- master
|
|
|
|
|
|
|
|
deploy:
|
|
|
|
stage: deploy
|
|
|
|
before_script:
|
2020-11-10 21:04:33 +01:00
|
|
|
- eval $(ssh-agent -s)
|
2020-11-10 20:42:15 +01:00
|
|
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
|
|
|
- mkdir -p ~/.ssh
|
|
|
|
- chmod 700 ~/.ssh
|
|
|
|
script:
|
|
|
|
- ssh -o StrictHostKeyChecking=no -p $SSH_PORT $SSH_DESTINATION "cd $PATH_TO_APPLICATION; $UPGRADE_COMMAND;"
|