what are you trying to achieve: Pull Request analysis
To replicate the problem, there is one *.cs file changed in the Foo.Bar folder compared to sonar.pullrequest.base however, the code request has ‘No code files were found for analysis.’
Below is the sonar scanner log for the specific folder.
INFO: ------------- Run sensors on module Foo.Bar
INFO: Sensor IaC CloudFormation Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC CloudFormation Sensor [iac] (done) | time=56ms
INFO: Sensor IaC Kubernetes Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC Kubernetes Sensor [iac] (done) | time=33ms
INFO: Sensor C# Project Type Information [csharp]
INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms
INFO: Sensor C# Analysis Log [csharp]
INFO: Roslyn version: 4.4.0.0
INFO: Language version: CSharp7_3
INFO: Concurrent execution: enabled
INFO: Sensor C# Analysis Log [csharp] (done) | time=1ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor HTML [web]
INFO: Sensor HTML is restricted to changed files only
INFO: Sensor HTML [web] (done) | time=1ms
INFO: Sensor XML Sensor [xml]
INFO: Sensor XML Sensor is restricted to changed files only
INFO: Sensor XML Sensor [xml] (done) | time=20ms
INFO: Sensor TextAndSecretsSensor [text]
INFO: Sensor TextAndSecretsSensor is restricted to changed files only
INFO: Sensor TextAndSecretsSensor [text] (done) | time=633ms
INFO: Sensor VB.NET Project Type Information [vbnet]
INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=0ms
INFO: Sensor VB.NET Analysis Log [vbnet]
INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=0ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=1ms
INFO: Sensor CSS Rules [javascript]
INFO: Sensor CSS Rules is restricted to changed files only
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor CSS Rules [javascript] (done) | time=0ms
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend]
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=0ms
INFO: Sensor IaC Docker Sensor [iac]
INFO: Sensor IaC Docker Sensor is restricted to changed files only
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC Docker Sensor [iac] (done) | time=6ms
INFO: Sensor Serverless configuration file sensor [security]
INFO: 0 Serverless function entries were found in the project
INFO: 0 Serverless function handlers were kept as entrypoints
INFO: Sensor Serverless configuration file sensor [security] (done) | time=1ms
INFO: Sensor AWS SAM template file sensor [security]
INFO: Sensor AWS SAM template file sensor [security] (done) | time=0ms
INFO: Sensor AWS SAM Inline template file sensor [security]
INFO: Sensor AWS SAM Inline template file sensor [security] (done) | time=0ms
Are you running this build in a CI / CD environment or locally? If locally, have you made sure that you’ve committed the changed file to your local branch?
Based on the logs, it seems there are issues when the scanner tries to collect changed files and lines for your project.
INFO: SCM collecting changed files in the branch
WARN: \\jenkins.mirror\MainSolution.git\objects\.probe-6861a7ba-21da-4a92-a9f8-35c96dbc34e5
java.nio.file.AccessDeniedException: \\jenkins.mirror\MainSolution.git\objects\.probe-6861a7ba-21da-4a92-a9f8-35c96dbc34e5
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:235)
at java.base/java.nio.file.Files.newByteChannel(Files.java:371)
at java.base/java.nio.file.Files.createFile(Files.java:648)
at org.eclipse.jgit.util.FS$FileStoreAttributes.measureFsTimestampResolution(FS.java:565)
at org.eclipse.jgit.util.FS$FileStoreAttributes.lambda$3(FS.java:430)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
INFO: Merge base sha1: 93d907a2918a45d10af32209e1c294514fb832e2
INFO: SCM collecting changed files in the branch (done) | time=1103ms
INFO: Indexing files of module 'Application.Schedule'
INFO: Base dir: C:\Temp\SonarQube\git\Scheduler\Application.Scheduler
INFO: Source paths: Application.cs, Application.Designer.cs, CommonFindFunctions....
INFO: Excluded sources: **/*Blending**
INFO: SCM writing changed lines
WARN: \\jenkins.mirror\MainSolution.git\objects\pack\.probe-1ddf2dcc-d631-4ef1-a381-84d0e3f86540
java.nio.file.AccessDeniedException: \\jenkins.mirror\MainSolution.git\objects\pack\.probe-1ddf2dcc-d631-4ef1-a381-84d0e3f86540
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:235)
at java.base/java.nio.file.Files.newByteChannel(Files.java:371)
at java.base/java.nio.file.Files.createFile(Files.java:648)
at org.eclipse.jgit.util.FS$FileStoreAttributes.measureFsTimestampResolution(FS.java:565)
at org.eclipse.jgit.util.FS$FileStoreAttributes.lambda$3(FS.java:430)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
The user executing the scan doesn’t seem to have access to view the .git folder within the project.
Can you go into more details about how the git clone is happening to bring your project into the Jenkins pipeline? What could be preventing access to the .git folder?
I ran into this same problem, on SonarQube Server 2025.1.0.102418 (previously we had 9.9.8)
For us the problem was we were scanning a folder that wasn’t actually part of source control. It was in the .gitignore
/sonar/
and then we’d copy some files in there and maybe download some dependencies, whatever it is to get the files to scan.
Our sonar-project.properties had these:
sonar.projectBaseDir=sonar
sonar.sources=.
And the problem only shows up on PR builds in Jenkins. The same revision on a branch will scan just fine and find all the source.
For us the solution was to add:
sonar.scm.disabled=true
We were already getting the warnings that blame wasn’t going to work, so might as well disable the scm sensor. Then all the files were there again on PR builds.
This was all working before on the ancient 9.9.8 version.