GitLab-Ci将覆盖率值提取到变量中以进行阈值比较

时间:2019-03-21 15:32:08

标签: gitlab code-coverage gitlab-ci

我在coverage中有一个GitLab任务已设置为某个阈值,这意味着每个不满足阈值条件的构建都应设置为失败。

此处是我的coverage运行中的输出

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18:00 min
[INFO] Finished at: 2019-03-21T15:23:37+00:00
[INFO] Final Memory: 65M/876M
[INFO] ------------------------------------------------------------------------
coverage line-rate="43.76%"

coverage中的.gitlab-ci.yml任务按原样配置

coverage:
  coverage: '/coverage line-rate="(\d+(?:\.\d+)?%)"/'
  variables:
    min_coverage: 50
    coverage_result: ${coverage}
    coverage_test: '/coverage line-rate="(\d+(?:\.\d+)?%)"'
  stage: test
  script:
  - make coverage
  - echo coverage
  - echo "${coverage}"
  - echo "${coverage_result}"
  - echo "${min_coverage}"
  - echo "${coverage_test}"
  - if [ "${min_coverage}" -gt "${coverage}" ]; then exit 1 fi

我无法提取用于43.76比较的if

0 个答案:

没有答案