# Sonarqube analysis fails Not Inside Git Work Tree

**URL:** <https://community.sonarsource.com/t/sonarqube-analysis-fails-not-inside-git-work-tree/39068>\
**Category:** SonarQube Server / Community Build\
**Tags:** sonarqube, java\
**Created:** [February 23, 2021, 4:59am UTC](https://community.sonarsource.com/t/sonarqube-analysis-fails-not-inside-git-work-tree/39068 "2021-02-23T04:59:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmad\_Mahdi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ahmad_mahdi/32/17943_2.png) [@Ahmad\_Mahdi](https://community.sonarsource.com/u/Ahmad_Mahdi)\
**Post date:** [February 23, 2021, 4:59am UTC](https://community.sonarsource.com/t/sonarqube-analysis-fails-not-inside-git-work-tree/39068/1 "2021-02-23T04:59:32Z")

</div>

version :sonarqube: :8.6.0.39681  
Maven:3.6  
Sprint tool suite:4.7.1.RELEASE  
fixing some error  
so i’m new at sonar, its only been 2 day since i try sonar ,i already run the server using startsonar bat i already create server and token for it but ever single time i try to analyze there is always an error saying not inside a git work tree nevertheless we didnt really use any git in our code(maybe thats a problem?). I Search for the same problem on this forum that already fix the same error, and they are using projectBaseDir,si i try to add them but to no avail the error is still there.  
here the error:

> [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project ad1treasury-api: Not  
> inside a Git work tree: D:\my\_kom\api → [Help 1]  
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:son  
> ar (default-cli) on project ad1treasury-api: Not inside a Git work tree: D:\my\_kom\api  
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)  
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)  
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)  
> at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)  
> at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)  
> at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)  
> at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)  
> at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)  
> at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)  
> at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)  
> at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)  
> at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)  
> at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)  
> at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)  
> at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)  
> at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)  
> at java.lang.reflect.Method.invoke (Method.java:566)  
> at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)  
> at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)  
> at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)  
> at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)  
> Caused by: org.apache.maven.plugin.MojoExecutionException: Not inside a Git work tree: D:\my\_kom\api  
> at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute (ScannerBootstrapper.java:67)  
> at org.sonarsource.scanner.maven.SonarQubeMojo.execute (SonarQubeMojo.java:104)  
> at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)  
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)  
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)  
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)  
> at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)  
> at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)  
> at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)  
> at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)  
> at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)  
> at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)  
> at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)  
> at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)  
> at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)  
> at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)  
> at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)  
> at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)  
> at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)  
> at java.lang.reflect.Method.invoke (Method.java:566)  
> at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)  
> at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)  
> at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)  
> at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)  
> Caused by: org.sonar.api.utils.MessageException: Not inside a Git work tree: D:\my\_kom\api  
> [ERROR]  
> [ERROR]  
> [ERROR] For more information about the errors and possible solutions, please read the following articles:  
> [ERROR] [Help 1] [MojoExecutionException - Apache Maven - Apache Software Foundation](http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException)

and here is sonar.source and sonar.projectBaseDir in pom.xml

> ```
> <properties>
> <java.version>11</java.version>
> <sonar.projectBaseDir>D:\my_kom\api</sonar.projectBaseDir>
> <sonar.source>D:\my_kom\api</sonar.source>
> </properties>
> 
> ```

But the problem Still persist, i did use mvn verify sonar:sonar(error with the same problem) i use mvn clean install 3 times still didnt work.please somebody tell me how should i fix it? do i need a connection to git? or do i need to tweak my setting, if i did need to tweak them where should i tweak them and what i need to tweak?

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [February 23, 2021, 8:39pm UTC](https://community.sonarsource.com/t/sonarqube-analysis-fails-not-inside-git-work-tree/39068/2 "2021-02-23T20:39:26Z")

</div>

Hi,

Welcome to the community!

Your first step here is to comment-out that properties section you’ve added to the pom; you shouldn’t need to set any of those values.

Then make sure you’re running the analysis from the git checkout directory; presumably this should correspond to the project root. As a trivial example, your command history would look something like this:

```auto
$ git clone git@github.com:Organization/repo.git
# clone happens...
$ cd repo
$ mvn clean install sonar:sonar
# analysis happens...

```

&nbsp;  
HTH,  
Ann

---

<div class="post-metadata">

**Author:** ![Ahmad\_Mahdi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ahmad_mahdi/32/17943_2.png) [@Ahmad\_Mahdi](https://community.sonarsource.com/u/Ahmad_Mahdi)\
**Post date:** [February 24, 2021, 1:34am UTC](https://community.sonarsource.com/t/sonarqube-analysis-fails-not-inside-git-work-tree/39068/3 "2021-02-24T01:34:28Z")

</div>

ah i see, so you have to use git for sonarqube?

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [February 24, 2021, 12:54pm UTC](https://community.sonarsource.com/t/sonarqube-analysis-fails-not-inside-git-work-tree/39068/4 "2021-02-24T12:54:23Z")

</div>

Hi,

You don’t have to use any particular SCM or an SCM at all. The here problem is that there _is_ an SCM involved but the Scanner can’t collect data from it. If you’d like to turn off SCM integration (not recommended!!!) you can disable it in the project settings or via the analysis properties: `-Dsonar.scm.disabled=true` on the analysis command line.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![Ahmad\_Mahdi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ahmad_mahdi/32/17943_2.png) [@Ahmad\_Mahdi](https://community.sonarsource.com/u/Ahmad_Mahdi)\
**Post date:** [March 10, 2021, 8:01am UTC](https://community.sonarsource.com/t/sonarqube-analysis-fails-not-inside-git-work-tree/39068/5 "2021-03-10T08:01:19Z")

</div>

ah i see So in certain project you have to set SCM huh.Thank you Ann

---

<div class="post-metadata">

**Author:** ![Ahmad\_Mahdi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ahmad_mahdi/32/17943_2.png) [@Ahmad\_Mahdi](https://community.sonarsource.com/u/Ahmad_Mahdi)\
**Post date:** [March 10, 2021, 8:02am UTC](https://community.sonarsource.com/t/sonarqube-analysis-fails-not-inside-git-work-tree/39068/6 "2021-03-10T08:02:19Z")

</div>

Alright i get a work Around for this problem which is using sonar scanner  
Which you can find how to set up here  
[https://docs.sonarqube.org/display/SONARQUBE52/Installing+and+Configuring+SonarQube+Scanner](https://docs.sonarqube.org/display/SONARQUBE52/Installing+and+Configuring+SonarQube+Scanner)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [March 17, 2021, 8:02am UTC](https://community.sonarsource.com/t/sonarqube-analysis-fails-not-inside-git-work-tree/39068/7 "2021-03-17T08:02:29Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
