provs/.gitlab-ci.yml

133 lines
3.7 KiB
YAML
Raw Normal View History

2021-02-14 09:12:50 +00:00
image: openjdk:11-jdk-slim
2021-02-10 19:24:43 +00:00
stages:
- build
- test
- publish
2021-11-24 18:18:46 +00:00
- fatjar
- release
2021-02-10 19:24:43 +00:00
before_script:
- echo "---------- Start CI ----------"
- export GRADLE_USER_HOME=`pwd`/.gradle
- chmod +x gradlew
- echo "------ commit tag ---------------"
- echo $CI_COMMIT_TAG
2021-02-10 19:24:43 +00:00
2021-11-24 18:18:46 +00:00
cache:
paths:
- .gradle/wrapper
- .gradle/caches
2021-02-10 19:24:43 +00:00
build:
stage: build
script:
- echo "---------- build stage ----------"
2021-11-24 18:18:46 +00:00
- ./gradlew assemble
2021-02-10 19:24:43 +00:00
artifacts:
paths:
- build/libs/*.jar
expire_in: 1 week
test:
stage: test
2021-11-24 18:18:46 +00:00
rules:
- if: $CI_COMMIT_TAG == null # don't run for git tags
2021-02-25 18:57:06 +00:00
image: docker:latest
2021-02-10 19:24:43 +00:00
services:
- docker:dind
dependencies:
- build
2021-02-25 18:57:06 +00:00
before_script:
- echo "---------- BEFORE -------------"
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
2021-02-10 19:24:43 +00:00
script:
2021-02-25 18:57:06 +00:00
- echo "---------- TEST -------------"
- apk update && apk add bash openjdk11
- export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker run --privileged -dit --name provs_test -v /var/run/docker.sock:/var/run/docker.sock $CI_REGISTRY_IMAGE
- docker inspect -f '{{.State.Running}}' provs_test
- ./gradlew test -Dtestdockerwithoutsudo=true
artifacts:
when: on_failure
paths:
- build/reports/tests/test
reports:
junit: build/test-results/test/TEST-*.xml
2021-02-10 19:24:43 +00:00
2021-11-24 18:18:46 +00:00
2021-04-27 16:32:08 +00:00
publish:
stage: publish
2021-11-25 10:12:34 +00:00
rules:
- if: $CI_COMMIT_TAG == null # don't run for git tags
2021-02-10 19:24:43 +00:00
script:
- ./gradlew jar
2021-04-27 16:32:08 +00:00
- ./gradlew publish
2021-02-10 19:24:43 +00:00
artifacts:
paths:
- build/libs/*.jar
expire_in: 2 months
2021-11-24 18:18:46 +00:00
2021-12-03 09:41:33 +00:00
fatjars:
2021-11-24 18:18:46 +00:00
stage: fatjar
rules:
# Do no allow manually triggered pipelines to prevent duplicates!
# Instead rerun the pipeline created with the last push
- if: $CI_PIPELINE_SOURCE != "push"
when: never
# Only execute when a valid version tag like v1.0, 2.3 or similar is given
# Required is always one point like 1.0
- if: $CI_COMMIT_REF_NAME == "master" # fix: && $CI_COMMIT_TAG =~ /^v?[0-9]+[.][0-9]+([.][0-9]+)?$/
2021-11-24 18:18:46 +00:00
before_script:
- echo $CI_JOB_ID
# Writing FATJAR_JOB_ID variable to environment file, as variable is needed in the release stage.
- echo FATJAR_JOB_ID=$CI_JOB_ID >> generate_executables.env
script:
- echo "---------- create fatjar ----------"
- ./gradlew fatJarLatest
2021-12-03 09:41:33 +00:00
- ./gradlew fatJarK3s
2021-11-24 18:18:46 +00:00
artifacts:
paths:
- 'build/libs/provs.jar'
2021-12-03 09:41:33 +00:00
- 'build/libs/provs-server.jar'
2021-11-24 18:18:46 +00:00
reports:
# To ensure we've access to this file in the next stage
dotenv: generate_executables.env
expire_in: 6 months
release:
stage: release
rules:
# Do no allow manually triggered pipelines to prevent duplicates!
# Instead rerun the pipeline created with the last push
- if: $CI_PIPELINE_SOURCE != "push"
when: never
# Only execute when a valid version tag like v1.0, 2.3 or similar is given
# Required is always one point like 1.0
- if: $CI_COMMIT_REF_NAME == "master" && $CI_COMMIT_TAG =~ /^v?[0-9]+[.][0-9]+([.][0-9]+)?$/
2021-11-24 18:31:45 +00:00
needs:
2021-12-03 09:45:44 +00:00
- job: fatjars
2021-11-24 18:31:45 +00:00
artifacts: true
image: registry.gitlab.com/gitlab-org/release-cli:latest
2021-11-24 18:18:46 +00:00
script:
- echo '------------ creating a release -------------'
- echo 'Fatjar Job ID:'
- echo $FATJAR_JOB_ID
release:
name: 'Release $CI_COMMIT_TAG'
description: 'Release of provs'
tag_name: '$CI_COMMIT_TAG'
ref: '$CI_COMMIT_TAG'
assets:
links:
- name: provs.jar
url: https://gitlab.com/domaindrivenarchitecture/provs/-/jobs/${FATJAR_JOB_ID}/artifacts/raw/build/libs/provs.jar
2021-12-03 09:41:33 +00:00
- name: provs-server.jar
url: https://gitlab.com/domaindrivenarchitecture/provs/-/jobs/${FATJAR_JOB_ID}/artifacts/raw/build/libs/provs-server.jar
2021-11-24 18:18:46 +00:00
2021-02-10 19:24:43 +00:00
after_script:
2021-02-25 18:57:06 +00:00
- echo "---------- End CI ----------"