solatium/.gitlab-ci.yml

129 lines
4 KiB
YAML
Raw Permalink Normal View History

image: maven:3.6.0-jdk-8
2019-09-19 23:28:29 +02:00
variables:
# This will supress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
2019-09-19 23:34:44 +02:00
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true"
2019-09-19 23:28:29 +02:00
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `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"
2019-09-23 21:48:42 +02:00
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
2019-09-19 23:28:29 +02:00
# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
2019-09-22 22:14:52 +02:00
# Define a cache with the key: ${CI_COMMIT_REF_SLUG} so that jobs of each branch always use the same cache
2019-09-19 23:28:29 +02:00
cache:
2019-09-22 22:14:52 +02:00
key: ${CI_COMMIT_REF_SLUG}
2019-09-19 23:28:29 +02:00
paths:
- .m2/repository
stages:
2019-09-19 22:53:14 +02:00
- compile
- test
2019-09-22 18:11:08 +02:00
- analyse
- build
mvn-compile:
2019-09-19 22:53:14 +02:00
stage: compile
script:
2019-09-22 22:14:52 +02:00
- "mvn $MAVEN_CLI_OPTS clean compile"
2019-09-19 22:53:14 +02:00
mvn-unit-test:
stage: test
coverage: '/Total.*?([0-9]{1,3})%/'
script:
- "mvn $MAVEN_CLI_OPTS clean test"
- "cat target/site/jacoco-ut/index.html"
2019-09-22 18:39:09 +02:00
mvn-integration-test:
stage: test
coverage: '/Total.*?([0-9]{1,3})%/'
2019-09-22 18:39:09 +02:00
script:
- "mvn $MAVEN_CLI_OPTS clean verify -Dskip.surefire.tests"
- "cat target/site/jacoco-it/index.html"
2019-09-22 22:14:52 +02:00
bash-E2E-api-test:
stage: test
script:
2019-09-23 14:31:07 +02:00
- "apt-get -qq update"
2019-09-23 14:21:24 +02:00
- "apt-get -qq install netcat-openbsd -y"
- "bash apiE2ETest.sh"
mvn-sonar-analyse:
stage: analyse
2019-09-23 16:32:17 +02:00
coverage: '/Total.*?([0-9]{1,3})%/'
script:
2019-09-23 16:32:17 +02:00
- "mvn $MAVEN_CLI_OPTS clean verify"
- "mvn $MAVEN_CLI_OPTS sonar:sonar -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.organization=$SONAR_ORGANIZATION -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_LOGIN"
- "cat target/site/jacoco/index.html"
2019-09-22 22:14:52 +02:00
mvn-package:
stage: build
2019-09-22 22:14:52 +02:00
script:
2019-09-23 16:32:17 +02:00
- "mvn $MAVEN_CLI_OPTS clean install -Dmaven.test.skip=true"
2019-09-22 22:14:52 +02:00
artifacts:
paths:
- target/*.jar
expire_in: 1 day
2019-09-27 09:54:28 +02:00
except:
- master
- tags
2019-09-22 22:14:52 +02:00
mvn-master-package:
stage: build
2019-09-22 22:14:52 +02:00
script:
2019-09-23 16:32:17 +02:00
- "mvn $MAVEN_CLI_OPTS clean install -Dmaven.test.skip=true"
2019-09-22 22:14:52 +02:00
artifacts:
paths:
- target/*.jar
2019-09-27 09:54:28 +02:00
expire_in: 30 days
2019-09-22 22:14:52 +02:00
only:
- master
2019-09-27 09:54:28 +02:00
- tags
.docker-before-template: &before-docker-script
before_script:
- "VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)"
- "ARTIFACT_ID=$(./mvnw help:evaluate -Dexpression=project.artifactId -q -DforceStdout)"
- "./mvnw $MAVEN_CLI_OPTS clean install -Dmaven.test.skip=true"
- "docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY"
docker-master-build-image:
2019-09-23 21:18:00 +02:00
image: registry.gitlab.com/berufsschul-ae/solatium/docker-openjdk8:latest
stage: build
2019-09-23 21:58:36 +02:00
services:
- docker:dind
only:
- master
<<: *before-docker-script
script:
- "docker build -t $CI_REGISTRY_IMAGE:latest --build-arg FILE_PATH=target/${ARTIFACT_ID}-${VERSION}.jar ."
- "docker push $CI_REGISTRY_IMAGE:latest"
docker-dev-build-image:
2019-09-23 21:28:45 +02:00
image: registry.gitlab.com/berufsschul-ae/solatium/docker-openjdk8:latest
2019-09-23 21:58:36 +02:00
stage: build
2019-09-23 21:48:42 +02:00
services:
- docker:dind
only:
- dev
2019-09-26 11:10:07 +02:00
<<: *before-docker-script
script:
- "docker build -t $CI_REGISTRY_IMAGE:dev --build-arg FILE_PATH=target/${ARTIFACT_ID}-${VERSION}.jar ."
- "docker push $CI_REGISTRY_IMAGE:dev"
docker-tags-build-image:
2019-09-23 21:18:00 +02:00
image: registry.gitlab.com/berufsschul-ae/solatium/docker-openjdk8:latest
stage: build
2019-09-23 21:58:36 +02:00
services:
- docker:dind
only:
- tags
2019-09-26 11:10:07 +02:00
<<: *before-docker-script
script:
- "docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG --build-arg FILE_PATH=target/${ARTIFACT_ID}-${VERSION}.jar ."
- "docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"