Error observed:
After getting help with a previous error on here, my PR’s not getting decorated (which is now fixed) we set out to try and remove the “Shallow checkout” warning. I changed the pipeline to include checkout: self and fetchDepth: 0. Scan still runs successfully, but my PR scan no longer shows any code files scanned or issues in the Sonar Cloud interface.
I have added issues to the code, which normally would be called out, so I know there are enough changes to produce an error. How can I troubleshoot this? I’ve tried adding the sonar.projectBaseDir as well and tried different paths with no luck, either the scan fails because it can’t find the path provided, or it is like in the pictures, seemingly empty.
We run sonar scan from the dockerfile. If I don’t add the fetchDepth: 0 it works, but then I get the “Shallow checkout” warning.
I’ve now tested this in another project, and I’m getting the 0 files result after adding in the .git folder to the docker container running the scan. Before copying in the .git folder we get the SCM provider autodetection failed warning.
Bringing in the .git folder is definitely the right move. If all you’re changing is your Azure Pipelines YML file, I’m not surprised to hear that SonarQube Cloud isn’t identifying any changes.
If you go ahead and make a minor change to an actual code file, do you see the change?
Does this have anything to do with it? And how to fix it?
Why does it say 4 changes in the branch in the first portion, then 0 changes a bit later in the run? Still on the same step: dotnet sonarscanner end
What effect does it have if we ignore the “Shallow fetch” warning? Do we lose anything by just using it as it is, as it seems to work when I don’t disable it in the pipeline @Colin ? What are the advantages of turning it off other than making the warning disappear?
@Colin to add to this issue I’ve now run the pipeline twice, once with shallow fetch off, and once with it on and I’ve compared the two pipeline runs in detail. The first thing I’m noticing is that in the working run it looks like this:
It looks like I may have figured out the issue on my own finally. With the different folder structures I did some testing and I noticed that when I copied the .git folder, I was copying the .git folder into .git, instead of into the working directory. I don’t know why it was working like that with shallow fetch and not without it, but after changing from COPY .git .git to COPY .git . I now have successful scans with fetchDepth: 0 in my pipeline.