【发布时间】:2019-07-26 12:33:17
【问题描述】:
我正在尝试为 python 项目设置 gitlab ci 管道,但我遇到了一些无法解析 coverage.xml 文件的 sonarqube 客户端问题
我得到的错误如下:
INFO: Python test coverage
INFO: Parsing report '/builds/core-tech/tools/nlu/mix-nlu-middleware/server/tests/cov.xml'
WARN: Invalid directory path in 'source' element: /bolt-webserver/bolt
WARN: Invalid directory path in 'source' element: /bolt-webserver/tests
ERROR: Cannot resolve the file path 'base.py' of the coverage report, the file does not exist in all <source>.
ERROR: Cannot resolve 404 file paths, ignoring coverage measures for those files
INFO: Sensor Cobertura Sensor for Python coverage [python] (done) | time=74ms
INFO: Sensor PythonXUnitSensor [python]
INFO: Sensor PythonXUnitSensor [python] (done) | time=20ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
覆盖文件 (cov.xml) 以此开头:
<?xml version="1.0" ?>
<coverage branch-rate="0" branches-covered="0" branches-valid="0" complexity="0" line-rate="0.3476" lines-covered="10369" lines-valid="29833" timestamp="1564079534753" version="4.4.2">
<!-- Generated by coverage.py: https://coverage.readthedocs.io -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
<source>/bolt-webserver/bolt</source>
<source>/bolt-webserver/tests</source>
</sources>
<packages>
<package branch-rate="0" complexity="0" line-rate="0.55" name=".">
<classes>
<class branch-rate="0" complexity="0" filename="base.py" line-rate="0.5955" name="base.py">
<methods/>
<lines>
<line hits="1" number="1"/>
<line hits="1" number="2"/>
<line hits="1" number="3"/>
<line hits="1" number="4"/>
<line hits="1" number="5"/>
<line hits="1" number="7"/>
<line hits="1" number="9"/>
<line hits="1" number="10"/>
.......................
声纳是这样调用的:
- sonar-scanner -Dsonar.projectKey=mix-nlu-middleware -Dsonar.sources=./server -Dsonar.host.url=$SONAR_SERVER_HOST -Dsonar.login=$SONAR_LOGIN -Dsonar.python.coverage.reportPaths=server/tests/cov.xml -Dsonar.junit.reportPaths=server/tests/junit-report.xml
项目树如下所示:
.
+-- CONTRIBUTING.md
+-- gen_version.sh
+-- package-lock.json
+-- README.md
+-- scripts
│ +-- .....
+-- server
│ +-- alembic.ini
│ +-- bolt
│ │ +-- .....
│ +-- Bolt.egg-info
│ │ +-- .....
│ +-- conf
│ │ +-- .....
│ +-- dev-requirements.txt
│ +-- Dockerfile
│ +-- Dockerfile-dev
│ +-- http.log
│ +-- MANIFEST.in
│ +-- pytest.ini
│ +-- requirements.txt
│ +-- scripts
│ │ +-- .....
│ +-- sdks
│ │ +-- ....
│ +-- server.log
│ +-- setup.py
│ +-- templates
│ │ +-- .....
│ +-- tests
│ │ +-- .....
│ \-- version.properties
\-- test.txt
知道我在这里做错了什么吗?
我也尝试在项目和文件系统的根文件夹中创建路径 /bolt-webserver/bolt 但仍然没有成功。
conv.xml 中提到的“base.py”文件和其他文件位于“/builds/core-tech/tools/nlu/mix-nlu-middleware/server/tests”下
【问题讨论】:
标签: python sonarqube pytest gitlab-ci gitlab-ci-runner