代码拉取完成,页面将自动刷新
image: adoptopenjdk:13-jdk-hotspot
workflow:
rules:
- if: $CI_MERGE_REQUEST_IID
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == "web"
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
DO_DEPLOY:
value: "false"
description: "Whether (true) or not (false) to deploy."
NO_BUILD_NUMBER:
value: "false"
description: "Whether (true) or not (false) to exclude the build number from the artifacts' version numbers."
before_script:
# Put GRADLE_USER_HOME into the cache directory so the wrapper is not
# re-downloaded for every job.
- export GRADLE_USER_HOME=/cache/.gradle
cache:
key: ${CI_COMMIT_REF_SLUG}
stages:
- build
- test
build:
stage: build
tags:
- opentcs-runner
script:
- echo "CI_PIPELINE_IID is $CI_PIPELINE_IID"
- echo "DO_DEPLOY is $DO_DEPLOY"
- echo "NO_BUILD_NUMBER is $NO_BUILD_NUMBER"
- 'if [ "$DO_DEPLOY" = "true" ]; then
echo "Executing build with deployment...";
./gradlew clean build publish jacocoLogAggregatedCoverage -PNO_BUILD_NUMBER="$NO_BUILD_NUMBER";
else
echo "Executing build without deployment...";
./gradlew clean build jacocoLogAggregatedCoverage -PNO_BUILD_NUMBER="$NO_BUILD_NUMBER";
fi'
coverage: '/Branch Coverage: ([0-9.]+)%/'
artifacts:
paths:
- build/distributions/*.zip
- openTCS-*/build/reports/checkstyle/*.xml
- openTCS-*/build/test-results/test/TEST-*.xml
reports:
junit: openTCS-*/build/test-results/test/TEST-*.xml
when: always
expire_in: 1 week
ensure_tests_passed:
stage: test
tags:
- opentcs-runner
variables:
CONCATENATED_REPORT_FILE: concatenated-test-reports.xml
script:
- echo "Checking test reports for failures..."
- rm -f $CONCATENATED_REPORT_FILE
- find . -name "TEST-*.xml" -exec cat '{}' + >> $CONCATENATED_REPORT_FILE
# There are examples of simply using 'grep -L "<failure", but the
# grep we have here doesn't provide the expected exit status with
# that, so we stick to plain grep and an if-else clause.
- 'if grep "<failure" $CONCATENATED_REPORT_FILE ; then
echo "There are failed tests - failing this job...";
false;
else
echo "No failed tests here.";
true;
fi'
code_quality:
stage: test
tags:
- opentcs-runner
variables:
CODE_CLIMATE_FILE: gl-code-quality-report.json
script:
- echo "Installing dependencies required for violations-command-line..."
- apt update && apt upgrade -y
- apt install -y nodejs npm
- npm install -g npx
- echo "Converting CheckStyle reports to CodeClimate report..."
- npx violations-command-line@1.21.0 -cc $CODE_CLIMATE_FILE -print-violations false -diff-print-violations true -v "CHECKSTYLE" "." ".*checkstyle/.*\.xml$" "Checkstyle"
- sed -i.bak -e "s,$CI_PROJECT_DIR/,,g" $CODE_CLIMATE_FILE
artifacts:
reports:
codequality: $CODE_CLIMATE_FILE
rules:
- if: '$CODE_QUALITY_DISABLED'
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"' # Run code quality job in merge request pipelines
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' # Run code quality job in pipelines on the master branch (but not in other branch pipelines)
- if: '$CI_COMMIT_TAG' # Run code quality job in pipelines for tags
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。