SonarQube with shallow clone warning even with shallow disabled on Jenkins build
Asked Answered
M

3

16

I have a Jenkins server building a solution using MSBuild. Shallow Clone is not enabled (on Advanced Clone Behaviours), so I supposed it's getting all the last commits. And I'm using SonarQube to analyze. I set to run the Begin Analysis before build and the End Analysis after build is complete. The SonarQube Analysis finishes successfully, but I'm receiving a warning:

Shallow clone detected during the analysis. Some files will miss SCM information. This will affect features like auto-assignment of issues. Please configure your build to disable shallow clone.

Someone knows what I'm missing to SonarQube works fine?

Marinara answered 22/11, 2019 at 18:49 Comment(2)
No usable info on the documentation page?Leaguer
Yes! I have read before, but now I check the info regarding a full clone, so I searched about that and posted now the answer :)Marinara
M
0

I have fixed! When I disabled the Shallow Clone on Jenkins, it was still missing the past commits, so I had to run some commands on GIT bash inside the repository folder:

git fetch --depth=1000000

(unless you have more than 1 million commits)

then to confirm that I have removed the shallow:

git fetch --unshallow

After wait the next build and analysis, now has disappeared the warning and I can see the authors!

Marinara answered 25/11, 2019 at 15:56 Comment(2)
That means ur using no more shallow clones after using this command. right?Encyst
fatal: --unshallow on a complete repository does not make senseWiseman
C
28

I was getting the same warning in sonarcloud for one of my github repository integrated with sonarcloud.

sonarcloud shallow clone warning github

So if someone is looking for the option to disable shallow clone in github actions workflow, then just edit the yml file and use the fetch-depth: 0 option with actions/checkout@v2 step to disable shallow clone.

The complete example is mentioned below

    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0

For more detailed information visit - https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches

Cervantes answered 21/6, 2020 at 15:7 Comment(2)
Any idea how to do the same on Azure DevOps?Michaelemichaelina
@Michaelemichaelina fetchDepth: 1 https://mcmap.net/q/632019/-shallow-fetch-for-repositoryAvoidance
A
4

As described in documentation: https://docs.travis-ci.com/user/customizing-the-build#sts=Git%20Clone%20Depth%20#

Just disable git fetch depth limit in .travis.yml as follows:

git:
  depth: false

Otherwise you are git cloning twice.

Aplacental answered 6/4, 2020 at 5:41 Comment(0)
M
0

I have fixed! When I disabled the Shallow Clone on Jenkins, it was still missing the past commits, so I had to run some commands on GIT bash inside the repository folder:

git fetch --depth=1000000

(unless you have more than 1 million commits)

then to confirm that I have removed the shallow:

git fetch --unshallow

After wait the next build and analysis, now has disappeared the warning and I can see the authors!

Marinara answered 25/11, 2019 at 15:56 Comment(2)
That means ur using no more shallow clones after using this command. right?Encyst
fatal: --unshallow on a complete repository does not make senseWiseman

© 2022 - 2024 — McMap. All rights reserved.