I need to set up sonarqube on some projects via Gitlab CI and when the job is running I got an warning :
WARN: Shallow clone detected, no blame information will be provided. You can convert to non-shallow with 'git fetch --unshallow'.
INFO: SCM Publisher 0/223 source files have been analyzed (done) | time=3ms
WARN: Missing blame information for the following files:
So it skips all files to analize
I don’t understand because on git documentation, a shallow repository will have a file .git/shallow in the repo but I don’t have this file. So it’s not a shallow clone repo.
sonar:
stage: analysis
only:
- test-sonar
except:
- tags
when: on_success
allow_failure: false
variables:
EXCLUDE: node_modules/**, reports/**
GIT_DEPTH: 0 # Tells git to fetch all the branches of the project, required by the analysis task
script:
- mkdir reports
- cat .git/shallow
- dependency-check --scan . --format "ALL" --project "IFS WebApp Frontend" -o reports
- sonar-scanner -Dsonar.projectKey=ifs-webapp-frontend -Dsonar.sources=. -Dsonar.host.url=https://sonar.development.sii -Dsonar.login=cc0fc5f6a99f4a80cc488f2552d4cad12eba909d -Dsonar.qualitygate.wait=true -Dsonar.exclusions="${EXCLUDE}" -Dsonar.dependencyCheck.xmlReportPath"reports/dependency-check-report.xml" -Dsonar.dependencyCheck.htmlReportPath="reports/dependency-check-report.html"
But I still got this error, I try to change project but still the same thing Is there a way to see the GIT_DEPTH variable is used?
WARN: Shallow clone detected, no blame information will be provided. You can convert to non-shallow with 'git fetch --unshallow'.
INFO: SCM Publisher 0/223 source files have been analyzed (done) | time=3ms
WARN: Missing blame information for the following files:
WARN: * AAAA/MyProject/Services/Expense/XXX/Interfaces/IDocReferenceObjectAPI.cs
WARN: * AAAA/MyProject/Helpers/DateTime/DateTimeExtensions.cs
WARN: * AAAA/MyProject/Repositories/Expense/v2/XXX/ExpenseLineRepository.cs
WARN: ...
Ok, another thing you can try is to go on your GitLab project settings > CI/CD > General pipelines and check that you use git clone and not git fetch. Make sure as well that the .gitlab-ci.yml file you changed is the one on the branch you are building (I don’t know how familiar you are with gitlab ^^)