Sonarqube series four getting started

Generalize

  • sonarqube supports importing test reports, but it does not support testing, nor does it generate test reports
  • Support wildcard
    ?    匹配单个字符
    *     匹配任意字符
    * *   匹配任意路径
    
  • For more information, please refer to the official website of sonarqube

Test case statistics

Parameter names corresponding to different languages

Language parameter name
Java / Kotlin sonar.junit.reportPaths
Python sonar.python.xunit.reportPath

Used in maven as follows:

mvn clean test sonar:sonar   \
  -Dmaven.test.failure.ignore=true \
  -Dsonar.host.url=http://127.0.0.1:9000     \
  -Dsonar.login=$SONARQUBE_TOKEN   \
  -Dsonar.ws.timeout=300 \
  -Dmaven.test.skip=false \
  -Dsonar.junit.reportPaths='./litemall-db/target/surefire-reports,./litemall-db/target/surefire-reports'

Coverage statistics

Parameter names corresponding to different languages

Language parameter name
Java / Kotlin / Scala / JVM sonar.coverage.jacoco.xmlReportPaths
Python sonar.python.coverage.reportPaths

Way 1 maven

mvn sonar:sonar \
  -Dsonar.host.url=http://127.0.0.1:9000   \
  -Dsonar.login=$SONARQUBE_TOKEN \
  -Dsonar.ws.timeout=300 \
  -Dsonar.projectKey= 自定义 \
  -Dsonar.projectName=自定义

Method 2 Manual

Custom path

SONARQUBE_HOST=http:127.0.0.1:9000 
sonar-scanner \
  -Dsonar.host.url=$SONARQUBE_HOST    \
  -Dsonar.login=$SONARQUBE_TOKEN   \
  -Dsonar.projectKey=自定义 \
  -Dsonar.projectName=自定义 \
  -Dsonar.sources=$(echo **/src | sed 's# #,#g')  \
  -Dsonar.java.binaries="**/target" \
  -Dsonar.junit.reportPaths=$(find . -name "surefire-reports"  | xargs  | sed 's# #,#g') \
  -Dsonar.coverage.jacoco.xmlReportPaths="**/jacoco/jacoco.xml"

Guess you like

Origin blog.csdn.net/dabaoting/article/details/114254178