image: maven:latest variables: LC_ALL: "en_US.UTF-8" LANG: "en_US.UTF-8" LANGUAGE: "en_US" LIB_NAME: "ms_specific" MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version" 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 -Djava.awt.headless=true" GIT_DEPTH: "2" SECURE_LOG_LEVEL: "debug" JACOCO_CSV_LOCATION: '${CI_PROJECT_DIR}/build_reporting/target/site/jacoco-aggregate-ut/jacoco.csv' JACOCO_XML_LOCATION: '${CI_PROJECT_DIR}/build_reporting/target/site/jacoco-aggregate-ut/jacoco.xml' PROJECT_RELEASE_PACKAGE: '${CI_PROJECT_DIR}/target/*-dist.zip' include: - template: Dependency-Scanning.gitlab-ci.yml - template: Secret-Detection.gitlab-ci.yml stages: - assemble - test - package - release cache: paths: - ".m2/repository" assemble: stage: assemble tags: - docker except: - tags script: | mvn $MAVEN_CLI_OPTS generate-sources compile test after_script: - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }' $JACOCO_CSV_LOCATION coverage: '/([0-9]{1,3}.[0-9]*).%.covered/' artifacts: when: always reports: junit: "**/target/surefire-reports/TEST-*.xml" paths: - $JACOCO_CSV_LOCATION - $JACOCO_XML_LOCATION buildDistributionPackage: stage: package tags: - docker except: - tags - /^feature/.*$/i script: | export VERSION=$(mvn -B help:evaluate -Dexpression=project.version -B | grep -v "\[INFO\]" | grep -Po "\d+\.\d+\.\d+((-\w*)+)?") echo "Build full package of version $VERSION" mvn $MAVEN_CLI_OPTS verify -DskipTests echo "VERSION=$VERSION" >> variables.env artifacts: name: "${CI_PROJECT_NAME}-${CI_COMMIT_SHORT_SHA}" when: always reports: dotenv: variables.env paths: - $PROJECT_RELEASE_PACKAGE release: stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest tags: - docker needs: - job: buildDistributionPackage artifacts: true when: manual only: - master script: | echo "Releasing version $VERSION of $LIB_NAME" echo "Publishing version $VERSION to public EGIZ maven" mvn $MAVEN_CLI_OPTS deploy artifacts: name: "${CI_PROJECT_NAME}-${CI_COMMIT_SHORT_SHA}-release" expire_in: never paths: - $PROJECT_RELEASE_PACKAGE