一个伪linux粉丝的blog

  1. 首页
  2. unix/linux
  3. 正文

Sonar Not inside a Git work tree: /workspace

27 1 月, 2021 1654点热度 1人点赞 0条评论

今天客户有一个故障,日志里面有类似Not inside a Git work tree: /workspace 报错,结果排查了几个小时,几乎崩溃,记录一下。

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar (default-cli) on project wire-rope-tension2-service: Not inside a Git work tree: /workspace -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar (default-cli) on project wire-rope-tension2-service: Not inside a Git work tree: /workspace
....
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.sonar.api.utils.MessageException: Not inside a Git work tree: /workspace
[ERROR]
[ERROR]

根据特征 ,找到 这个https://groups.google.com/g/sonarqube/c/GyTqFzFKGgM

里面有

the correct configuration is more like:
sonar.projectBaseDir=$WORKSPACE/my-subdir
sonar.sources=.
sonar.scm.provider=git

然后参考修改

mvn clean test package sonar:sonar \
-Dsonar.projectKey=$SONAR_PROJECT_KEY \
-Dsonar.host.url=$SONAR_HOST_URL \
-Dsonar.login=$SONAR_LOGIN \
-Dsonar.sources=$SONAR_SOURCES \
-Dsonar.java.binaries=$SONAR_JAVA_BINARIES \
-Dsonar.java.covergaePlugin=jacoco \
-Duser.timezone=Asia/Shanghai \
-Dsonar.jacoco.reportPaths=target/jacoco.exec -X

增加2行-Dsonar.scm.provider=git 和 -Dsonar.projectBaseDir=/workspace,结果报错依然相同。

后面尝试修改镜像,修改maven的原始settings.xml 文件,陷入更多的错误。

解决

后来同事找到这个 https://docs.sonarqube.org/display/SONARQUBE50/SCM+support

里面 有2段介绍

Supported SCM engines

Git and Subversion are natively supported in SonarQube. Auto-detection will works if the root directory of your project contains .git or .svn folders. Otherwise you can force the provider using -Dsonar.scm.provider=git or -Dsonar.scm.provider=svn.

Disabling SCM support

It is possible to disable SCM support in the "General Settings > SCM" administration page or setting property sonar.scm.disabled=true during project analysis.

于是增加一个字段 -Dsonar.scm.disabled=true

mvn clean test package sonar:sonar \
-Dsonar.projectKey=$SONAR_PROJECT_KEY \
-Dsonar.host.url=$SONAR_HOST_URL \
-Dsonar.login=$SONAR_LOGIN \
-Dsonar.sources=$SONAR_SOURCES \
-Dsonar.java.binaries=$SONAR_JAVA_BINARIES \
-Dsonar.java.covergaePlugin=jacoco \
-Duser.timezone=Asia/Shanghai \
-Dsonar.scm.disabled=true \
-Dsonar.jacoco.reportPaths=target/jacoco.exec -X

sonar阶段顺利执行完成

后记

其实自己找到过7的介绍

https://docs.sonarqube.org/7.0/SCMsupport.html

里面 有1段介绍

It is possible to disable SCM support in the "General Settings > SCM" administration page or setting property sonar.scm.disabled=true during project analysis.

没有5.0 的前半段介绍,也就想不起来这个参数和前面有关联。

相关文章:

  1. Google Chrome 1.0.154.136 Final
  2. Docker_Conflunce
  3. Can't execute jar- file: “no main manifest attribute”
  4. SourceForge宣布2008年度社区选择奖
标签: Sonar
最后更新:27 1 月, 2021

wanjie

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

This site uses Akismet to reduce spam. Learn how your comment data is processed.

归档
分类
  • network / 332篇
  • Uncategorized / 116篇
  • unix/linux / 121篇
  • 业界资讯 / 38篇
  • 公司杂事 / 11篇
  • 数码影像 / 12篇
  • 美剧 / 3篇
  • 美图共赏 / 21篇
  • 英语学习 / 3篇
标签聚合
Ubuntu openssl wget d90 kernel google-chrome ldap gitlab 天翼live dreamhost空间 浏览器 postgres debian kubectl 邮件归档 网站运营 ssh 虚拟主机 squid jira docker deepseek dreamhost 泰国 Google Voice nexus VPS Nginx k8s Google

COPYRIGHT © 2008-2025 wanjie.info. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang