SOnarqube show jave error fail to create lock in

Hi Team,

I am trying to check my dotnet core project on sonarqube but I see this error. I have installed jave and jdk 8 and 11 still the same issu.

I follow this but I dont have any folder scanner or any sub-folders,

Can you please tell me what I did wrong.
myCodes

sonar.projectKey=PsTracker
dotnet sonarscanner begin /k:"PsTracker" /d:sonar.host.url="localhost" /d:sonar.login=""
dotnet build
dotnet sonarscanner end /d:sonar.login=""

error

ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Failed to create lock in /var/lib/jenkins/workspace/project_PSTrackSonarQube/.scannerwork/.sonar_lock
	at org.sonar.scanner.scan.DirectoryLock.tryLock(DirectoryLock.java:52)
	at org.sonar.scanner.scan.ProjectLock.tryLock(ProjectLock.java:46)
	at org.sonar.scanner.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:154)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:134)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.io.FileNotFoundException: /var/lib/jenkins/workspace/project_PSTrackSonarQube/.scannerwork/.sonar_lock (Permission denied)
	at java.base/java.io.RandomAccessFile.open0(Native Method)
	at java.base/java.io.RandomAccessFile.open(RandomAccessFile.java:345)
	at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:259)
	at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:214)
	at org.sonar.scanner.scan.DirectoryLock.tryLock(DirectoryLock.java:46)
	... 21 more
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE

Hi,

First, you need to revoke the token you just published to the world^. :slight_smile:

Regarding your error, it looks like analysis doesn’t have the permissions it needs:

It’s probably easiest to grant that account all permissions to the workspace directory, recursive.

 
HTH,
Ann

Hi Thanks for your help. Now Program run sucessfully but sonarqube not analysisng the C# dotnetcore codes. I follow some other question, I have installed the dotnet in server. The sonarqube is runing on ubuntu so I cant install MSBuild.exe.


INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=0ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=0ms
INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
INFO: Calculating CPD for 0 files
INFO: CPD calculation finished
INFO: Analysis report generated in 64ms, dir size=73 KB
INFO: Analysis report compressed in 8ms, zip size=10 KB
INFO: Analysis report uploaded in 168ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=PsTracker
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AYBuvloRDYCEsJxA_rZl
INFO: Analysis total time: 12.373 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 13.394s
INFO: Final Memory: 7M/34M
INFO: -------------------

When I tried witout jenkins I see this error again,

java.lang.ExceptionInInitializerError
        at com.sonar.sslr.api.typed.ActionParser.<init>(ActionParser.java:59)
        at org.sonar.javascript.parser.JavaScriptParser.<init>(JavaScriptParser.java:33)
        at org.sonar.javascript.parser.JavaScriptParserBuilder.createParser(JavaScriptParserBuilder.java:31)
        at org.sonar.plugins.javascript.JavaScriptSensor.<init>(JavaScriptSensor.java:136)
        at org.sonar.plugins.javascript.JavaScriptSensor.<init>(JavaScriptSensor.java:100)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
        at org.picocontainer.injectors.AbstractInjector.newInstance(AbstractInjector.java:145)
        at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:342)
        at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
        at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
        at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
        at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
        at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
        at org.picocontainer.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:606)
        at org.picocontainer.DefaultPicoContainer.getComponents(DefaultPicoContainer.java:587)
        at org.sonar.core.platform.ComponentContainer.getComponentsByType(ComponentContainer.java:290)
        at org.sonar.scanner.bootstrap.AbstractExtensionDictionnary.completeScannerExtensions(AbstractExtensionDictionnary.java:82)
        at org.sonar.scanner.bootstrap.AbstractExtensionDictionnary.getExtensions(AbstractExtensionDictionnary.java:77)
        at org.sonar.scanner.bootstrap.AbstractExtensionDictionnary.getFilteredExtensions(AbstractExtensionDictionnary.java:67)
        at org.sonar.scanner.sensor.ModuleSensorExtensionDictionnary.selectSensors(ModuleSensorExtensionDictionnary.java:40)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$0(ModuleSensorsExecutor.java:52)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:52)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:400)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:392)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at jdk.proxy1/jdk.proxy1.$Proxy0.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @112d1c8e
        at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:464)
        at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:336)
        at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
        at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91)
        at net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
        at net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
        at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116)
        at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291)
        at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:221)
        at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:174)
        at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:153)
        at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:73)
        ... 53 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @112d1c8e
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
        at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
        at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
        at net.sf.cglib.core.ReflectUtils$1.run(ReflectUtils.java:61)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
        at net.sf.cglib.core.ReflectUtils.<clinit>(ReflectUtils.java:52)
        at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:243)
        at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
        at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:329)
        ... 65 more
ERROR:
The SonarScanner did not complete successfully
09:52:25.935  Post-processing failed. Exit code: 1

Hi,

You’re not going to get analysis without a build. In fact, I just realized I should have called that out in my response to your initial post:

I believe that needs to be rebuild instead of build so that every file is recompiled.

For the “without Jenkins” error… Let’s set that aside for now. It seems like a different thing - which would require a different thread.

 
Ann

Hi Ann,

Thanks a lot for your help but still I have same issu. This is my output

Started by user [devops](http://local:8080/user/admin) 
Running as SYSTEM [EnvInject] - Loading node environment variables. 
Building in workspace /var/lib/jenkins/workspace/PsTracker2 [PsTracker2] 
$ /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube/bin/sonar-scanner -Dsonar.host.url=[http://local:9003](http://local:9003/) -Dproject.settings=/var/lib/jenkins/workspace/PSTrackerPull -Dsonar.projectKey=PsTracker2 -DMsBuild.exe=/t:Rebuild '-DSonarScanner.MSBuild.exe=end /d:sonar.login="token"' -Dsonar.projectBaseDir=/var/lib/jenkins/workspace/PsTracker2 
INFO: Scanner configuration file: /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube/conf/sonar-scanner.properties 
INFO: Project root configuration file: NONE 
INFO: SonarScanner 4.7.0.2747 
INFO: Java 11.0.15 Private Build (64-bit) 
INFO: Linux 5.13.0-37-generic amd64 
INFO: User cache: /var/lib/jenkins/.sonar/cache 
INFO: Scanner configuration file: /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube/conf/sonar-scanner.properties 
INFO: Project root configuration file: NONE 
INFO: Analyzing on SonarQube server 7.9.2 
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent) 
INFO: Load global settings 
INFO: Load global settings (done) | time=59ms 
INFO: Server id: BF41A1F2-AX9_N5sEMKMu8qURqeLV 
INFO: User cache: /var/lib/jenkins/.sonar/cache 
INFO: Load/download plugins 
INFO: Load plugins index 
INFO: Load plugins index (done) | time=45ms 
INFO: Load/download plugins (done) | time=105ms 
INFO: Process project properties 
INFO: Execute project builders 
INFO: Execute project builders (done) | time=3ms 
INFO: Project key: PsTracker2 
INFO: Base dir: /var/lib/jenkins/workspace/PsTracker2 
INFO: Working dir: /var/lib/jenkins/workspace/PsTracker2/.scannerwork 
INFO: Load project settings for component key: 'PsTracker2' 
INFO: Load project settings for component key: 'PsTracker2' (done) | time=20ms 
INFO: Load quality profiles 
INFO: Load quality profiles (done) | time=170ms 
INFO: Detected Jenkins 
INFO: Load active rules 
INFO: Load active rules (done) | time=2966ms WARN: SCM provider autodetection failed. Please use "sonar.scm.provider" to define SCM of your project, or disable the SCM Sensor in the project settings. 
INFO: Indexing files... 
INFO: Project configuration: 
INFO: 0 files indexed 
INFO: ------------- Run sensors on module PsTracker2 
INFO: Load metrics repository 
INFO: Load metrics repository (done) | time=25ms 
WARNING: An illegal reflective access operation has occurred 
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/var/lib/jenkins/.sonar/cache/Id/sonar-javascript-plugin.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) 
WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1 
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations 
WARNING: All illegal access operations will be denied in a future release 
INFO: Sensor JaCoCo XML Report Importer [jacoco] 
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms 
INFO: Sensor JavaXmlSensor [java] 
INFO: Sensor JavaXmlSensor [java] (done) | time=3ms 
INFO: ------------- Run sensors on project 
INFO: Sensor Zero Coverage Sensor 
INFO: Sensor Zero Coverage Sensor (done) | time=0ms 
INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it. 
INFO: Calculating CPD for 0 files 
INFO: CPD calculation finished 
INFO: Analysis report generated in 67ms, dir size=73 KB 
INFO: Analysis report compressed in 9ms, zip size=10 KB 
INFO: Analysis report uploaded in 63ms 
INFO: ANALYSIS SUCCESSFUL, you can browse http://local:9003/dashboard?id=PsTracker2 
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report 
INFO: More about the report processing at http://localhost:9003/api/ce/task?id=AYBwYmGfdZw-hx206X5m 
INFO: Analysis total time: 4.957 s 
INFO: ------------------------------------------------------------------------ 
INFO: EXECUTION SUCCESS 
INFO: ------------------------------------------------------------------------ 
INFO: Total time: 5.870s 
INFO: Final Memory: 7M/34M 
INFO: ------------------------------------------------------------------------ Finished: SUCCESS

And This is How I tried in jenkins
As it show in sonarqube

sonar.projectKey=PsTracker2
SonarScanner.MSBuild.exe begin /k:"PsTracker2" /d:sonar.host.url="http://local:9003" /d:sonar.login="123456abcde"
MsBuild.exe /t:Rebuild
SonarScanner.MSBuild.exe end /d:sonar.login="123456abcd"

2nd way

sonar.projectKey=PsTracker2
dotnet sonarscanner begin /k:"PsTracker" /d:sonar.host.url="http://local:9003" /d:sonar.login="12345abcde"
dotnet /t:Rebuild
dotnet sonarscanner end /d:sonar.login="12345abcde"

Result is the same, Finish sucess no result. Please elp me to find wha I am doing wong. ?
Best Regards,

Hi,

I’ve reformatted your analysis log to re-insert the linebreaks to make it readable.

And I see that it starts with:

That’s not the SonarScanner for .NET. Your analysis is using the vanilla SonarScanner, which explains why your C# files aren’t getting analyzed.

 
Ann

Thank you Ann,

This issu I have notice. At local host when I make project I can see .net option to select. However when I follow these steps on sonarqube on linux server There is no option to select for .net.

Screenshot (70)

I also checked all the plugins they are uptodate. Can you please tel me how can I use .net instad of vanila. Why There is not .net select option?, I have install the .net on server and also sdk.

Hi,

That is an excellent question, and one I’d like to follow up on. But first, what’s your SonarQube version?

As to getting started with .NET analysis, it’s unfortunate that the wizard isn’t help here, but it’s not required. The docs will get you started.

 
HTH,
Ann

I am using Version 7.9.2 and the documentation you send me I have followd tha alreay. Everything is installed accroding to that documantation.

Dotnet is installed
Tool ‘dotnet-sonarscanner’ is already installed.
certificates are up to date.

Hi,

Okay, that’s your problem.

Your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

7.9.2 → 8.9.8 → 9.4 (last step optional)

You may find the Upgrade Guide and the LTS-to-LTS Upgrade Notes helpful. If you have questions about upgrading, feel free to open a new thread for that here.

If your error persists after upgrade, please come back to us.

 
Ann

Dear Ann,
I have upgrade the sonarqube and now its up and running. The issue is half resolved. When I create a project in sonarqube menually and then use cmd and follow the instructions the project upload and analyses sucessfully.

The other half problem is still there. When I use jenkines, project is uploaded but no analyses of codes.
I try Execute SonarQube Scanner as

sonar.projectKey=PsTrackerJenkins
sonar.login=xxx
sonar.password=xxx
dotnet tool install --global dotnet-sonarscanner
dotnet sonarscanner begin /k:"PsTrackerJenkins" /d:sonar.host.url="http://donamin.com"  /d:sonar.login="key"
dotnet build
dotnet sonarscanner end /d:sonar.login="key"

This is the output of this, I have also try with sonar-scanner.properties and the result is same.

Started by user [devops](http://domain8080/user/admin) Running as SYSTEM [EnvInject] - Loading node environment variables. Building in workspace /var/lib/jenkins/workspace/PsTrackerJenkins The recommended git tool is: NONE using credential PsTracker 
> git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/PsTrackerJenkins/.git # timeout=10 Fetching changes from the remote Git repository 
> git config remote.origin.url https://github.com/repo # timeout=10 Fetching upstream changes from https://github.com/repo 
> git --version # timeout=10 
> git --version # 'git version 2.25.1' using GIT_ASKPASS to set credentials 
> git fetch --tags --force --progress -- https://github.com/xxx* # timeout=10 
> git rev-parse refs/remotes/origin/dev^{commit} # timeout=10 Checking out Revision xxxx (refs/remotes/origin/dev) 
> git config core.sparsecheckout # timeout=10 
> git checkout -f xxxxxxx2af # timeout=10 Commit message: "Merge branch 'dev' of https://github.com// dev" 
> git rev-list --no-walk xxxxxxxxf # timeout=10 [PsTrackerJenkins] $ /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube/bin/sonar-scanner -Dsonar.host.url=[http://domain:9003](http://domain:9003/) ******** -Dproject.settings=/var/lib/jenkins/workspace/PsTrackerJenkins/ps-tracking-ordermicroservice -Dsonar.projectKey=PsTrackerJenkins '-Ddotnet=sonarscanner end /d:sonar.login="xxxxxxxxf"' -Dsonar.login=xxx -Dsonar.password=xxxxx -Dsonar.projectBaseDir=/var/lib/jenkins/workspace/PsTrackerJenkins WARN: Property 'sonar.login' with value 'xxxxxxxx' is overridden with value 'admin' 
INFO: Scanner configuration file: /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube/conf/sonar-scanner.properties 
INFO: Project root configuration file: NONE 
INFO: SonarScanner 4.7.0.2747 
INFO: Java 11.0.15 Private Build (64-bit) 
INFO: Linux 5.13.0-37-generic amd64 
INFO: User cache: /var/lib/jenkins/.sonar/cache 
INFO: Scanner configuration file: /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube/conf/sonar-scanner.properties 
INFO: Project root configuration file: NONE 
INFO: Analyzing on SonarQube server 9.4.0 
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent) 
INFO: Load global settings 
INFO: Load global settings (done) | time=219ms 
INFO: Server id: yjLQ9h_ 
INFO: User cache: /var/lib/jenkins/.sonar/cache 
INFO: Load/download plugins 
INFO: Load plugins index 
INFO: Load plugins index (done) | time=186ms 
INFO: Load/download plugins (done) | time=274ms 
INFO: Process project properties 
INFO: Process project properties (done) | time=1ms 
INFO: Execute project builders 
INFO: Execute project builders (done) | time=2ms 
INFO: Project key: PsTrackerJenkins 
INFO: Base dir: /var/lib/jenkins/workspace/PsTrackerJenkins 
INFO: Working dir: /var/lib/jenkins/workspace/PsTrackerJenkins/.scannerwork 
INFO: Load project settings for component key: 'PsTrackerJenkins' 
INFO: Load project settings for component key: 'PsTrackerJenkins' (done) | time=164ms 
INFO: Auto-configuring with CI 'Jenkins' 
INFO: Load quality profiles 
INFO: Load quality profiles (done) | time=201ms 
INFO: Load active rules 
INFO: Load active rules (done) | time=4631ms 
INFO: Load project repositories 
INFO: Load project repositories (done) | time=180ms 
INFO: Indexing files... 
INFO: Project configuration: 
INFO: 220 files indexed 
INFO: 88 files ignored because of scm ignore settings 
INFO: Quality profile for cs: Sonar way 
INFO: Quality profile for json: Sonar way 
INFO: ------------- Run sensors on module PsTrackerJenkins 
INFO: Load metrics repository 
INFO: Load metrics repository (done) | time=162ms 
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=6ms 
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=127ms 
INFO: Sensor CSS Rules [javascript] 
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped. 
INFO: Sensor CSS Rules [javascript] (done) | time=1ms 
INFO: Sensor C# Project Type Information [csharp] 
INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms 
INFO: Sensor C# Analysis Log [csharp] 
INFO: Sensor C# Analysis Log [csharp] (done) | time=12ms 
INFO: Sensor C# Properties [csharp] 
INFO: Sensor C# Properties [csharp] (done) | time=1ms 
INFO: Sensor HTML [web] 
INFO: Sensor HTML [web] (done) | time=3ms 
INFO: Sensor Text Sensor [text] 
INFO: 217 source files to be analyzed 
INFO: 217/217 source files have been analyzed 
INFO: Sensor Text Sensor [text] (done) | time=294ms 
INFO: Sensor VB.NET Project Type Information [vbnet] 
INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms 
INFO: Sensor VB.NET Analysis Log [vbnet] 
INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=13ms 
INFO: Sensor VB.NET Properties [vbnet] 
INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms 
INFO: ------------- Run sensors on project 
INFO: Sensor C# [csharp] 
WARN: Your project contains C# files which cannot be analyzed with the scanner you are using. To analyze C# or VB.NET, you must use the SonarScanner for .NET 5.x or higher, see https://redirect.sonarsource.com/doc/install-configure-scanner-msbuild.html 
INFO: Sensor C# [csharp] (done) | time=0ms 
INFO: Sensor Zero Coverage Sensor 
INFO: Sensor Zero Coverage Sensor (done) | time=4ms 
INFO: SCM Publisher SCM provider for this project is: git 
INFO: SCM Publisher 210 source files to be analyzed 
INFO: SCM Publisher 210/210 source files have been analyzed (done) | time=1199ms 
INFO: CPD Executor Calculating CPD for 0 files 
INFO: CPD Executor CPD calculation finished (done) | time=0ms 
INFO: Analysis report generated in 121ms, dir size=2.4 MB 
INFO: Analysis report compressed in 198ms, zip size=368.0 kB 
INFO: Analysis report uploaded in 200ms 
INFO: ANALYSIS SUCCESSFUL, you can find the results at: http://153.70.79.45:9003/dashboard?id=PsTrackerJenkins 
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report 
INFO: More about the report processing at http://domain:9003/api/ce/task?id=AYCJwIHt03gh7yjLRC7Y 
INFO: Analysis total time: 10.056 s 
INFO: ------------------------------------------------------------------------ 
INFO: EXECUTION SUCCESS 
INFO: ------------------------------------------------------------------------ 
INFO: Total time: 11.557s 
INFO: Final Memory: 16M/67M 
INFO: ------------------------------------------------------------------------ 
Finished: SUCCESS

Hi,

Here’s the problem:

As stated^, you need to use SonarScanner for .NET.

 
Ann

Hi, I have checked it already but for got to mentioned. I am running .net 6 and all the pakges are uptodate.
When I simply use the command line and push the codes to sonarqube they got analyze but when I use the jenkines they dont.
I have instlled the sonar scanner latest available, sonar for msbuild, and I have also installed the donet in server. exactilly as mentioned in doc.

Looking forward for your advice.
Regads,
Tauqeer.

Hi Tauqeer,

It’s not clear to me what you’re doing. You posted a standard begin / build / end sequence as what you’re doing, but then followed that immediately by a log that looks like it’s coming from SonarScanner - immediately after checkout & with no build (should actually be rebuild) in there.

If you’re dealing with C# code, you need to use the SonarScanner for .NET, and do a full rebuild every time.

 
Ann

Hi Ann,
Sorry for the messedup log. Here is the clear issu.
By using Execute SonarQube Scanner

My build commands.

sonar.projectKey=PSTrackerSonar
dotnet /home/devops/ sonarscanner begin /k:"PSTrackerSonar" /d:sonar.host.url="http://domain:90030"  /d:sonar.login="Key"
dotnet build -p:RunAnalyzersDuringBuild=true
dotnet build /var/lib/jenkins/workspace/PSTrackerPull/
dotnet sonarscanner end /d:sonar.login="Key"

In this try I didnt use any sonar-scanner.property file. I have followed the steps of doc, I downloaded the .NET5+ unziped in linux server home directory where jenkins is installed and edit the SonarQube.Analysis.xml and added the correct information.

I have also added the directory into the path where dotnet is installed.

Still I see this error log.

Running as SYSTEM
[EnvInject] - Loading node environment variables.
Building in workspace /var/lib/jenkins/workspace/PSTrackerSonar
The recommended git tool is: NONE
using credential PsTracker
 > git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/PSTrackerSonar/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/ # timeout=10
Fetching upstream changes from https://github.com/
 > git --version # timeout=10
 > git --version # 'git version 2.25.1'
using GIT_ASKPASS to set credentials 
 > git fetch --tags --force --progress -- https://github.com/ +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/dev^{commit} # timeout=10
Checking out Revision 488e1dc....... (refs/remotes/origin/dev)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 488e1dc...... # timeout=10
Commit message: "Merge branch 'dev' of https://github.com/ into dev"
 > git rev-list --no-walk 488e1dc........ # timeout=10
[PSTrackerSonar] $ /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube/bin/sonar-scanner -Dsonar.host.url=http://localhost:9000 ******** -Dsonar.projectKey=PSTrackerSonar '-Ddotnet=sonarscanner end /d:sonar.login="cfb0325a........."' -Dsonar.projectBaseDir=/var/lib/jenkins/workspace/PSTrackerSonar
INFO: Scanner configuration file: /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
**INFO: SonarScanner 4.7.0.2747**
INFO: Java 11.0.15 Private Build (64-bit)
INFO: Linux 5.13.0-37-generic amd64
INFO: User cache: /var/lib/jenkins/.sonar/cache
INFO: Scanner configuration file: /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
**INFO: Analyzing on SonarQube server 9.4.0**
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=86ms
INFO: Server id: 147..............._
INFO: User cache: /var/lib/jenkins/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=51ms
INFO: Load/download plugins (done) | time=138ms
INFO: Process project properties
INFO: Process project properties (done) | time=0ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=2ms
INFO: Project key: PSTrackerSonar
INFO: Base dir: /var/lib/jenkins/workspace/PSTrackerSonar
INFO: Working dir: /var/lib/jenkins/workspace/PSTrackerSonar/.scannerwork
INFO: Load project settings for component key: 'PSTrackerSonar'
INFO: Load project settings for component key: 'PSTrackerSonar' (done) | time=20ms
INFO: Auto-configuring with CI 'Jenkins'
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=60ms
INFO: Load active rules
INFO: Load active rules (done) | time=1529ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=33ms
INFO: Indexing files...
INFO: Project configuration:
INFO: 220 files indexed
INFO: 88 files ignored because of scm ignore settings
INFO: Quality profile for cs: Sonar way
INFO: Quality profile for json: Sonar way
INFO: ------------- Run sensors on module PSTrackerSonar
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=30ms
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=4ms
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=74ms
INFO: Sensor CSS Rules [javascript]
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor CSS Rules [javascript] (done) | time=2ms
INFO: Sensor C# Project Type Information [csharp]
INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms
INFO: Sensor C# Analysis Log [csharp]
INFO: Sensor C# Analysis Log [csharp] (done) | time=17ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=4ms
INFO: Sensor Text Sensor [text]
INFO: 217 source files to be analyzed
INFO: 217/217 source files have been analyzed
INFO: Sensor Text Sensor [text] (done) | time=476ms
INFO: Sensor VB.NET Project Type Information [vbnet]
INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms
INFO: Sensor VB.NET Analysis Log [vbnet]
INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=13ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms
INFO: ------------- Run sensors on project
INFO: Sensor C# [csharp]
WARN: Your project contains C# files which cannot be analyzed with the scanner you are using. To analyze C# or VB.NET, you must use the SonarScanner for .NET 5.x or higher, see https://redirect.sonarsource.com/doc/install-configure-scanner-msbuild.html
INFO: Sensor C# [csharp] (done) | time=0ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=6ms
INFO: CPD Executor Calculating CPD for 0 files
INFO: CPD Executor CPD calculation finished (done) | time=0ms
INFO: Analysis report generated in 137ms, dir size=2.3 MB
INFO: Analysis report compressed in 190ms, zip size=333.7 kB
INFO: Analysis report uploaded in 80ms
INFO: ANALYSIS SUCCESSFUL, you can find the results at: http://localhost:9000/dashboard?id=PSTrackerSonar
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AYCT.........
INFO: Analysis total time: 5.362 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 6.641s
INFO: Final Memory: 16M/60M
INFO: ------------------------------------------------------------------------
Finished: SUCCESS

Method 2

I used SonarScanner for MSBuild

Errors are.

SonarScanner for MSBuild 5.5.3
Using the .NET Core version of the Scanner for MSBuild
A value has already been supplied for this argument: begin. Existing: ''
Default properties file was found at /home/devops/SonarQube.Analysis.xml
Loading analysis properties from /home/devops/SonarQube.Analysis.xml
WARNING: Please specify the command 'begin' or 'end' to indicate whether pre- or post-processing is required. These parameters will become mandatory in a later release.
ERROR: Execution of SonarScanner for MSBuild failed (exit code 1)
Finished: FAILURE

I completly fail to understad the issue. Thanks in advance for your help.

Hi,

I have the sense that you’re still mixing your methods. begin isn’t relevant for sonarscanner. Unless that’s some alias you’ve created to SonarScanner.MSBuild.exe.

Please follow these docs as closely as you can.

 
Ann

Hi Ann,

I have tried the documentation again. I still didnt manage to find the issu.

Commit message: "Model Changes"
First time build. Skipping changelog.
ERROR: SonarScanner for MSBuild executable was not found for MsBuildForSonar
Finished: FAILURE

I see this error when I used SonarScanner for MSBuild - Begin Analysis.

I would like to mentioned here I am ubuntu server where jenken is running and sonarqube is in docker contanier. There is no way to have MSBuild.exe file there as we cant install on linux. I have give the path as mentioned in documentation and see this error. Any Advice any link for blog post other then documentation. ?

When I use the install auto from git I see this error

Unhandled Exception:
System.TypeLoadException: Could not load type of field 'SonarScanner.MSBuild.PreProcessor.WebClientDownloader:client' (1) due to: Could not load file or assembly 'System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=a3a' or one of its dependencies.
  at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.DoExecute (SonarScanner.MSBuild.PreProcessor.ProcessedArgs localSettings) [0x000d8] in <f7f995dc6>:0 
  at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.Execute (System.String[] args) [0x000aa] in <7f995dc6>:0 
  at SonarScanner.MSBuild.BootstrapperClass.PreProcess () [0x000ca] in <b52578e>:0 
  at SonarScanner.MSBuild.BootstrapperClass.Execute () [0x000b3] in <8b52578e>:0 
  at SonarScanner.MSBuild.Program.Execute (System.String[] args, SonarScanner.MSBuild.Common.ILogger logger) [0x001c7] in <578e>:0 
  at SonarScanner.MSBuild.Program.Execute (System.String[] args) [0x0006b] in <c8b52578e>:0 
  at SonarScanner.MSBuild.Program.Main (System.String[] args) [0x00060] in <b52578e>:0 
  at SonarScanner.MSBuild.Program.<Main> (System.String[] args) [0x0000c] in <8b52578e>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type of field 'SonarScanner.MSBuild.PreProcessor.WebClientDownloader:client' (1) due to: Could not load file or assembly 'System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=a3a' or one of its dependencies.
  at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.DoExecute (SonarScanner.MSBuild.PreProcessor.ProcessedArgs localSettings) [0x000d8] in <7f995dc6>:0 
  at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.Execute (System.String[] args) [0x000aa] in <f995dc6>:0 
  at SonarScanner.MSBuild.BootstrapperClass.PreProcess () [0x000ca] in <2578e>:0 
  at SonarScanner.MSBuild.BootstrapperClass.Execute () [0x000b3] in <578e>:0 
  at SonarScanner.MSBuild.Program.Execute (System.String[] args, SonarScanner.MSBuild.Common.ILogger logger) [0x001c7] in <8b52578e>:0 
  at SonarScanner.MSBuild.Program.Execute (System.String[] args) [0x0006b] in <ec8b52578e>:0 
  at SonarScanner.MSBuild.Program.Main (System.String[] args) [0x00060] in <52578e>:0 
  at SonarScanner.MSBuild.Program.<Main> (System.String[] args) [0x0000c] in <52578e>:0 
ERROR: Execution of SonarScanner for MSBuild failed (exit code 1)
Finished: FAILURE

I hope this time I mentioned my issu correctly and clearly.
Regards,

Hi,

You must be able to build your .NET code in order to analyze it. I suggest you try adding a Windows build agent to your Jenkins and try this there. (Sorry, but the details of that are beyond the scope of this community.)

 
Ann