0

以下は私の sonar.properties ファイルです:-

sonar.projectKey=code
sonar.projectName=PROJECT
sonar.projectVersion=0.0.1
sonar.sources=code
sonar.python.coverage.reportPath=code/coverage*.xml
sonar.python.coveragePlugin=cobertura
sonar.python.xunit.reportPath=TEST*.xml
sonar.sourceEncoding=UTF-8
sonar.pli.marginLeft=2
sonar.pli.marginRight=0

以下は私が実行しているコマンドです:-

$HOME/sonar-scanner-3.2.0.1227-linux/bin/sonar-scanner -Dsonar.verbose=false -Dsonar.projectKey=code -Dproject.settings=code/devops/sonar.properties -Dsonar.host.url=https://mysonar.net -Dsonar.login=$USERNAME -Dsonar.password=$PASSWORD

エラーログ:-

INFO: Python test coverage
INFO: Parsing report '/data/jenkins/workspace/master-ci/code/coverage.xml'
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 9.052s
INFO: Final Memory: 15M/397M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Line 3832 is out of range in the file code/src/driver.py (lines: 3831)
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] }
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?

Sonarqube バージョン:- バージョン 7.1 (ビルド 11001)LGPL v3Community Sonar-scanner:- 3.2.0.1227

4

1 に答える 1

0

1-空白を追加します。(coverage.xml ファイルの下部にあります)。これは、古い pytest テストで機能しました。

2-別のプロジェクトで、pytest、pytest-cov、およびカバレッジのパッケージを最新バージョンに更新しました。(魅力のように働きました)。

ここで問題が 1 つあります。最新の pytest バージョンに更新すると、conftest.py には存在しないメソッドが見つかる場合があります。例: 新しい get_closest_marker に置き換えることができる get_marker。または「リクエスト」などの予約語。最新のケースでは、request という名前のメソッドの名前を変更できます。

于 2021-07-26T17:51:15.803 に答える