Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SonarQube with shallow clone warning even with shallow disabled on Jenkins build

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?

like image 965
Samuel Finatto Avatar asked Nov 22 '19 18:11

Samuel Finatto


3 Answers

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

like image 124
Vivek Avatar answered Sep 22 '22 01:09

Vivek


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.

like image 30
surfealokesea Avatar answered Sep 19 '22 01:09

surfealokesea


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!

like image 23
Samuel Finatto Avatar answered Sep 22 '22 01:09

Samuel Finatto