Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Sonarqube客户端无法分析pytest覆盖率结果_Python_Sonarqube_Pytest_Gitlab Ci_Gitlab Ci Runner - Fatal编程技术网

Python Sonarqube客户端无法分析pytest覆盖率结果

Python Sonarqube客户端无法分析pytest覆盖率结果,python,sonarqube,pytest,gitlab-ci,gitlab-ci-runner,Python,Sonarqube,Pytest,Gitlab Ci,Gitlab Ci Runner,我正在尝试为python项目设置gitlab ci管道,但sonarqube客户端出现了一些问题,无法解析coverage.xml文件 我得到的错误如下: 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: /bol

我正在尝试为python项目设置gitlab ci管道,但sonarqube客户端出现了一些问题,无法解析coverage.xml文件

我得到的错误如下:

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]
项目树如下所示:

- 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,但仍然没有成功


“base.py”文件和conv.xml中提到的其他文件位于“/builds/core tech/tools/nlu/mix nlu middleware/server/tests”下。

好的。问题似乎来自cov.xml内容。sonarqube似乎无法仅根据测试文件的名称找到它们:filename=“base.py”
为了解决这个问题,我必须更新cov.xml,以便文件名字段包含完整的文件路径。filename=“/base.py”

您是手动完成的还是能够在pytest运行中完成的?我必须手动完成。我写了一个脚本,让meMind分享这个脚本?;)碰撞如何从文件名中找到文件的路径?我也想看看那个剧本。
.
+-- 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