Added some more stages such as release and refactored to use the gitlab registry
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
parent
34e91dcc0d
commit
3b7fff8a17
@ -1,13 +1,12 @@
|
|||||||
# This file is a template, and might need editing before it works on your project.
|
image: docker:latest
|
||||||
# Build JAVA applications using Apache Maven (http://maven.apache.org)
|
services:
|
||||||
# For docker image tags see https://hub.docker.com/_/maven/
|
- docker:dind
|
||||||
#
|
|
||||||
# For general lifecycle information see https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
|
|
||||||
|
|
||||||
# This template will build and test your projects
|
stages:
|
||||||
# * Caches downloaded dependencies and plugins between invocation.
|
- build
|
||||||
# * Verify but don't deploy merge requests.
|
- test
|
||||||
# * Deploy built artifacts from master branch only.
|
- package
|
||||||
|
- release
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
|
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
|
||||||
@ -17,9 +16,12 @@ variables:
|
|||||||
# when running from the command line.
|
# when running from the command line.
|
||||||
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
|
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
|
||||||
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
|
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
|
||||||
|
# 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
|
||||||
|
|
||||||
# This template uses jdk8 for verifying and deploying images
|
|
||||||
image: maven:3.6.3-jdk-14
|
|
||||||
|
|
||||||
# Cache downloaded dependencies and plugins between builds.
|
# Cache downloaded dependencies and plugins between builds.
|
||||||
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
|
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
|
||||||
@ -29,12 +31,54 @@ cache:
|
|||||||
|
|
||||||
# Compile
|
# Compile
|
||||||
compile: &compile
|
compile: &compile
|
||||||
|
# This template uses jdk8 for verifying and deploying images
|
||||||
|
image: maven:3.6.3-jdk-14
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- 'mvn $MAVEN_CLI_OPTS compile'
|
- 'mvn $MAVEN_CLI_OPTS compile'
|
||||||
|
cache:
|
||||||
|
key: "$CI_COMMIT_REF_NAME"
|
||||||
|
policy: push
|
||||||
|
paths: .m2/repository
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
test: &test
|
test: &test
|
||||||
|
image: maven:3.6.3-jdk-14
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- 'mvn $MAVEN_CLI_OPTS test'
|
- 'mvn $MAVEN_CLI_OPTS test'
|
||||||
|
cache:
|
||||||
|
key: "$CI_COMMIT_REF_NAME"
|
||||||
|
policy: pull
|
||||||
|
paths: .m2/repository
|
||||||
|
|
||||||
|
package:
|
||||||
|
image: maven:3.6.3-jdk-14
|
||||||
|
stage: package
|
||||||
|
script: 'mvn $MAVEN_CLI_OPTS assemble:single'
|
||||||
|
cache:
|
||||||
|
key: "$CI_COMMIT_REF_NAME"
|
||||||
|
policy: push
|
||||||
|
paths: .m2/repository
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- target/*.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
|
||||||
|
except:
|
||||||
|
- master
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user