138 lines
4.1 KiB
YAML
138 lines
4.1 KiB
YAML
stages:
|
|
- build
|
|
- test
|
|
- package
|
|
- publish
|
|
- release
|
|
|
|
.kotlin-job: &kotlin
|
|
image: domaindrivenarchitecture/ddadevops-kotlin
|
|
cache:
|
|
key: ${CI_COMMIT_REF_SLUG}
|
|
paths:
|
|
- .gradle/wrapper
|
|
- .gradle/caches
|
|
before_script:
|
|
- echo "---------- Start CI ----------"
|
|
- export GRADLE_USER_HOME=`pwd`/.gradle
|
|
- chmod +x gradlew
|
|
- echo "------ commit info ---------------"
|
|
- echo $CI_COMMIT_TAG
|
|
- echo $CI_COMMIT_REF_NAME
|
|
- echo "----------------------------------"
|
|
|
|
.tag_only: &tag_only
|
|
rules:
|
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
when: never
|
|
- if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
|
|
|
|
|
|
build:
|
|
<<: *kotlin
|
|
stage: build
|
|
script:
|
|
- pyb build
|
|
artifacts:
|
|
paths:
|
|
- build/libs/*.jar
|
|
expire_in: 1 week
|
|
|
|
|
|
test:
|
|
stage: test
|
|
image: docker:latest
|
|
services:
|
|
- docker:dind
|
|
dependencies:
|
|
- build
|
|
before_script:
|
|
- echo "---------- BEFORE -------------"
|
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
|
script:
|
|
- 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 -x assemble test -Dtestdockerwithoutsudo=true -DexcludeTags=extensivecontainertest,nonci
|
|
artifacts:
|
|
when: on_failure
|
|
paths:
|
|
- build/reports/tests/test
|
|
reports:
|
|
junit: build/test-results/test/TEST-*.xml
|
|
|
|
|
|
package:
|
|
<<: *kotlin
|
|
stage: package
|
|
script:
|
|
- ./gradlew -x assemble -x test jar
|
|
- ./gradlew -x assemble -x test -x jar uberjarDesktop
|
|
- ./gradlew -x assemble -x test -x jar uberjarServer
|
|
- ./gradlew -x assemble -x test -x jar uberjarSyspec
|
|
- cd build/libs/
|
|
- find . -type f -exec sha256sum {} \; | sort > sha256sum.lst
|
|
- find . -type f -exec sha512sum {} \; | sort > sha512sum.lst
|
|
artifacts:
|
|
paths:
|
|
- build/libs/*.jar
|
|
- build/libs/*.lst
|
|
|
|
|
|
publish-maven-package-to-gitlab:
|
|
<<: *kotlin
|
|
<<: *tag_only
|
|
stage: publish
|
|
script:
|
|
- ./gradlew -x assemble -x test publishLibraryPublicationToGitlabRepository
|
|
|
|
|
|
publish-maven-package-to-meissa:
|
|
<<: *kotlin
|
|
<<: *tag_only
|
|
stage: publish
|
|
allow_failure: true
|
|
script:
|
|
- apt-get update -y
|
|
- apt-get install -y iputils-ping ssh
|
|
- ping -c 2 repo.prod.meissa.de
|
|
- ssh-keyscan repo.prod.meissa.de
|
|
- ./gradlew -x assemble -x test publishLibraryPublicationToMeissaRepository
|
|
|
|
|
|
release-to-gitlab:
|
|
<<: *tag_only
|
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
stage: release
|
|
artifacts:
|
|
paths:
|
|
- 'build/libs/provs-desktop.jar'
|
|
- 'build/libs/provs-server.jar'
|
|
- 'build/libs/provs-syspec.jar'
|
|
- 'build/libs/sha256sum.lst'
|
|
- 'build/libs/sha512sum.lst'
|
|
script:
|
|
- apk --no-cache add curl
|
|
- |
|
|
release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
|
|
--assets-link "{\"name\":\"provs-desktop.jar\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/provs/-/jobs/${CI_JOB_ID}/artifacts/file/build/libs/provs-desktop.jar\"}" \
|
|
--assets-link "{\"name\":\"provs-server.jar\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/provs/-/jobs/${CI_JOB_ID}/artifacts/file/build/libs/provs-server.jar\"}" \
|
|
--assets-link "{\"name\":\"provs-syspec.jar\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/provs/-/jobs/${CI_JOB_ID}/artifacts/file/build/libs/provs-syspec.jar\"}" \
|
|
--assets-link "{\"name\":\"sha256sum.lst\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/provs/-/jobs/${CI_JOB_ID}/artifacts/file/build/libs/sha256sum.lst\"}" \
|
|
--assets-link "{\"name\":\"sha512sum.lst\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/provs/-/jobs/${CI_JOB_ID}/artifacts/file/build/libs/sha512sum.lst\"}" \
|
|
|
|
|
|
release-to-meissa:
|
|
<<: *kotlin
|
|
<<: *tag_only
|
|
stage: release
|
|
allow_failure: true
|
|
script:
|
|
- ./gradlew createReleaseAndUploadAssets
|
|
|
|
|
|
after_script:
|
|
- echo "---------- End CI ----------"
|