SonarQube + Jenkins Error 500 - jenkins

I have successfully integrated SonarQube and Jenkins using the SonarQube plugin for Jenkins. The Sonar analysis seems to be successful, but I cannot see the results on the Sonar dashboard. Here is the stacktrace:
INFO: Sensor SCM Sensor
INFO: SCM provider for this project is: git
INFO: 6 files to be analyzed
INFO: 6/6 files analyzed
INFO: Sensor SCM Sensor (done) | time=343ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=12ms
INFO: Sensor Code Colorizer Sensor
INFO: Sensor Code Colorizer Sensor (done) | time=1ms
INFO: Sensor CPD Block Indexer
INFO: JavaCpdBlockIndexer is used for java
INFO: Sensor CPD Block Indexer (done) | time=20ms
INFO: Calculating CPD for 6 files
INFO: CPD calculation finished
INFO: Analysis report generated in 65ms, dir size=39 KB
INFO: Analysis reports compressed in 187ms, zip size=23 KB
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 4.083s
INFO: Final Memory: 50M/385M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
org.sonarqube.ws.client.HttpException: Error 500 on http://localhost:9000/api/ce/submit?projectKey=helloworld&projectName=Simple%20Java%20project%20analyzed%20with%20the%20SonarQube%20Runner
at org.sonarqube.ws.client.BaseResponse.failIfNotSuccessful(BaseResponse.java:34)
at org.sonar.batch.bootstrap.BatchWsClient.failIfUnauthorized(BatchWsClient.java:99)
at org.sonar.batch.bootstrap.BatchWsClient.call(BatchWsClient.java:69)
at org.sonar.batch.report.ReportPublisher.upload(ReportPublisher.java:172)
at org.sonar.batch.report.ReportPublisher.execute(ReportPublisher.java:127)
at org.sonar.batch.phases.PublishPhaseExecutor.publishReportJob(PublishPhaseExecutor.java:64)
at org.sonar.batch.phases.PublishPhaseExecutor.executeOnRoot(PublishPhaseExecutor.java:51)
at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:86)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47)
at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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:240)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110)
at org.sonarsource.scanner.cli.Main.execute(Main.java:72)
at org.sonarsource.scanner.cli.Main.main(Main.java:60)
When I click on the link it says
{"errors":[{"msg":"HTTP method POST is required"}]}
I think the solution is to reconfigure SQ so it directly uses the target URL, but how do I do that?

In my sonar it doesn't put the binary data to MySQL so I change
max_allowed_packet = 16M to
#max_allowed_packet = 256M

I encountered the same error and Nicolas' comment about checking the sonar.log helped me diagnose the problem. I was running this on Windows as a Windows Service, and the user of the process was set to the default Local Service and so it was looking for a temp folder under C:\Windows\System32. I changed the user account to an actual user account and that solved the problem.
If the error in the log is about unable to find the temp folder, try checking the user account that Sonar is running under.

I had similar problem, the sollution was that the host parameter was given with 'http' not 'https' format, that was causing redirect which was loosing the POST information

It worked to me:
In Jenkins, go to Global Tool Configuration and look for SonarQube Scanner block.
Activate it. The error will be gone.
https://gabrielscavassa.wordpress.com/2016/07/21/jenkins-sonarqube/

Related

How to resolve this " org.sonarqube.ws.client.HttpException: Error 401 " error of sonarqube quality gates

How to resolve this " org.sonarqube.ws.client.HttpException: Error 401 " error of sonarqube quality gates.
i'm getting above error during third stage build pipeline in jenkins.
SonarQube-Scanner Version: 4.5.0.2216
SonarQube-Server Version: 8.6.0.39681
Jenkins-Server Version: 2.235.5
Below is my build pipeline
node {
stage('Clone the Git') {
git 'https://github.com/SonarSource/sonar-scanning-examples'
}
stage('SonarQube analysis') {
def scannerHome = tool 'sonarqube';
withSonarQubeEnv('sonarqube-server') {
sh "${scannerHome}/bin/sonar-scanner \
-D sonar.login=admin \
-D sonar.password=admin \
-D sonar.projectKey=sonarqubetest3 \
-D sonar.exclusions=vendor/**,resources/**,**/*.java \
-D sonar.host.url=http://192.168.0.4:9000/"
}
}
stage('Quality Gates'){
timeout(time: 1, unit: 'HOURS') {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
# Below is the complete jenkins job log
Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/sonar-qube-testing
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Clone the Git)
[Pipeline] git
The recommended git tool is: NONE
No credentials specified
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/SonarSource/sonar-scanning-examples # timeout=10
Fetching upstream changes from https://github.com/SonarSource/sonar-scanning-examples
> git --version # timeout=10
> git --version # 'git version 2.11.0'
> git fetch --tags --progress -- https://github.com/SonarSource/sonar-scanning-examples +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 1cbdd40467f475fcdbd8367ca00b65acbf774e3f (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 1cbdd40467f475fcdbd8367ca00b65acbf774e3f # timeout=10
> git branch -a -v --no-abbrev # timeout=10
> git branch -D master # timeout=10
> git checkout -b master 1cbdd40467f475fcdbd8367ca00b65acbf774e3f # timeout=10
Commit message: "Merge pull request #99 from SonarSource/pre-8.x-hardening"
> git rev-list --no-walk 1cbdd40467f475fcdbd8367ca00b65acbf774e3f # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (SonarQube analysis)
[Pipeline] tool
[Pipeline] withSonarQubeEnv
Injecting SonarQube environment variables using the configuration: sonarqube-server
[Pipeline] {
[Pipeline] sh
+ /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonarqube/bin/sonar-scanner -D sonar.login=admin -D sonar.password=admin -D sonar.projectKey=sonarqubetest3 -D sonar.exclusions=vendor/**,resources/**,**/*.java -D sonar.host.url=http://192.168.0.4:9000
INFO: Scanner configuration file: /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonarqube/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.5.0.2216
INFO: Java 1.8.0_242 Oracle Corporation (64-bit)
INFO: Linux 4.15.0-111-generic amd64
INFO: User cache: /var/jenkins_home/.sonar/cache
INFO: Scanner configuration file: /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonarqube/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: Analyzing on SonarQube server 8.6.0
INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
WARN: SonarScanner will require Java 11 to run starting in SonarQube 8.x
INFO: Load global settings
INFO: Load global settings (done) | time=658ms
INFO: Server id: BF41A1F2-AXaTGa1I2xlvXb1FgNjK
INFO: User cache: /var/jenkins_home/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=602ms
INFO: Load/download plugins (done) | time=649ms
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: sonarqubetest3
INFO: Base dir: /var/jenkins_home/workspace/sonar-qube-testing
INFO: Working dir: /var/jenkins_home/workspace/sonar-qube-testing/.scannerwork
INFO: Load project settings for component key: 'sonarqubetest3'
INFO: Load project settings for component key: 'sonarqubetest3' (done) | time=574ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=636ms
INFO: Auto-configuring with CI 'Jenkins'
INFO: Load active rules
INFO: Load active rules (done) | time=10366ms
INFO: Indexing files...
INFO: Project configuration:
INFO: Excluded sources: vendor/**, resources/**, **/*.java
INFO: Load project repositories
INFO: Load project repositories (done) | time=573ms
INFO: 105 files indexed
INFO: 12 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for cs: Sonar way
INFO: Quality profile for flex: Sonar way
INFO: Quality profile for js: Sonar way
INFO: Quality profile for kotlin: Sonar way
INFO: Quality profile for php: Sonar way
INFO: Quality profile for py: Sonar way
INFO: Quality profile for web: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: ------------- Run sensors on module sonarqubetest3
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=600ms
INFO: Sensor Python Sensor [python]
INFO: Starting global symbols computation
INFO: 9 source files to be analyzed
INFO: Starting rules execution
INFO: 9 source files to be analyzed
INFO: 9/9 source files have been analyzed
INFO: Sensor Python Sensor [python] (done) | time=6536ms
INFO: 9/9 source files have been analyzed
INFO: Sensor Cobertura Sensor for Python coverage [python]
INFO: Sensor Cobertura Sensor for Python coverage [python] (done) | time=23ms
INFO: Sensor PythonXUnitSensor [python]
INFO: Sensor PythonXUnitSensor [python] (done) | time=8ms
INFO: Sensor CSS Rules [cssfamily]
INFO: 2 source files to be analyzed
INFO: 2/2 source files have been analyzed
INFO: Sensor CSS Rules [cssfamily] (done) | time=1624ms
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 Kotlin Sensor [kotlin]
INFO: 1 source files to be analyzed
INFO: Sensor Kotlin Sensor [kotlin] (done) | time=902ms
INFO: Sensor KotlinSurefireSensor [kotlin]
INFO: 1/1 source files have been analyzed
INFO: parsing [/var/jenkins_home/workspace/sonar-qube-testing/target/surefire-reports]
INFO: Sensor KotlinSurefireSensor [kotlin] (done) | time=5ms
INFO: Sensor JavaScript analysis [javascript]
INFO: 1 source files to be analyzed
INFO: Version of TypeScript used during analysis: 3.8.3
INFO: 1/1 source files have been analyzed
INFO: Sensor JavaScript analysis [javascript] (done) | time=4872ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=1ms
INFO: Sensor JavaXmlSensor [java]
INFO: 8 source files to be analyzed
INFO: Sensor JavaXmlSensor [java] (done) | time=396ms
INFO: 8/8 source files have been analyzed
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=80ms
INFO: Sensor Flex [flex]
INFO: 2 source files to be analyzed
INFO: Sensor Flex [flex] (done) | time=107ms
INFO: 2/2 source files have been analyzed
INFO: Sensor Flex Cobertura [flex]
INFO: No Cobertura report provided (see 'sonar.flex.cobertura.reportPaths' property)
INFO: Sensor Flex Cobertura [flex] (done) | time=1ms
INFO: Sensor XML Sensor [xml]
INFO: 8 source files to be analyzed
INFO: 8/8 source files have been analyzed
INFO: Sensor XML Sensor [xml] (done) | time=182ms
INFO: Sensor PHP sensor [php]
INFO: Starting PHP symbol indexer
INFO: 1 source files to be analyzed
INFO: 1/1 source files have been analyzed
INFO: Starting PHP rules
INFO: 1 source files to be analyzed
INFO: 1/1 source files have been analyzed
INFO: No PHPUnit test report provided (see 'sonar.php.tests.reportPath' property)
INFO: No PHPUnit coverage reports provided (see 'sonar.php.coverage.reportPaths' property)
INFO: Sensor PHP sensor [php] (done) | time=353ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=2ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=1ms
INFO: ------------- Run sensors on project
INFO: Sensor C# [csharp]
WARN: No protobuf reports found. The C# files will not have highlighting and metrics.
WARN: No Roslyn issue reports were found. The C# files have not been analyzed.
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 Scanner for MSBuild 4.x, see https://redirect.sonarsource.com/doc/install-configure-scanner-msbuild.html
INFO: Sensor C# [csharp] (done) | time=1ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=16ms
INFO: CPD Executor 7 files had no CPD blocks
INFO: CPD Executor Calculating CPD for 8 files
INFO: CPD Executor CPD calculation finished (done) | time=28ms
INFO: Analysis report generated in 135ms, dir size=189 KB
INFO: Analysis report compressed in 77ms, zip size=70 KB
INFO: Analysis report uploaded in 581ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://192.168.0.4:9000/dashboard?id=sonarqubetest3
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://192.168.0.4:9000/api/ce/task?id=AXbH8OKO2xlvXb1FgSam
INFO: Analysis total time: 37.408 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 39.822s
INFO: Final Memory: 93M/761M
INFO: ------------------------------------------------------------------------
[Pipeline] }
[Pipeline] // withSonarQubeEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Quality Gates)
[Pipeline] sleep
Sleeping for 1 min 0 sec
[Pipeline] timeout
Timeout set to expire in 1 hr 0 min
[Pipeline] {
[Pipeline] waitForQualityGate
Checking status of SonarQube task 'AXbH8OKO2xlvXb1FgSam' on server 'sonarqube-server'
[Pipeline] }
[Pipeline] // timeout
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
org.sonarqube.ws.client.HttpException: Error 401 on http://192.168.0.4:9000/api/ce/task?id=AXbH8OKO2xlvXb1FgSam :
at org.sonarqube.ws.client.BaseResponse.failIfNotSuccessful(BaseResponse.java:36)
at hudson.plugins.sonar.client.HttpClient.getHttp(HttpClient.java:38)
at hudson.plugins.sonar.client.WsClient.getCETask(WsClient.java:51)
at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.checkTaskCompleted(WaitForQualityGateStep.java:234)
at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.start(WaitForQualityGateStep.java:171)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:286)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:179)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
at sun.reflect.GeneratedMethodAccessor1239.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:163)
at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:157)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:161)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
at WorkflowScript.run(WorkflowScript:19)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
at sun.reflect.GeneratedMethodAccessor1236.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
at sun.reflect.GeneratedMethodAccessor1659.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
at com.cloudbees.groovy.cps.Next.step(Next.java:83)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
I know "Error 401" means wrong credentials/Unauthorized but same creds are working at 2nd stage "SonarQube Analysis" of job build.
i have also added webhooks url for jenkins in sonarqube server as "http://192.168.0.4:8056/sonarqube-webhook/" but to no avail.
Can someone please help me out over here.
Thanks & Regards
When you use the "withSonarQubeEnv" pipeline step, it is expected that the string value provided matches the name of the SonarQube instance configured in Jenkins. In that configuration will be defined the sonarqube login credentials. If that string matches the SonarQube instance name, then the login credentials will be put into environment variables.
However, I believe this usually only expects to use the "token" authentication method, not the old-style "login" and "password" values. In the "token" method, the "SONAR_AUTH_TOKEN" environment variable is set to the "sonar.login" property, and the "sonar.password" value is just not set.
In fact, I don't believe the "task" api used inside the "waitForQualityGate" step can use anything but the "token" authentication method. To get this to work, you'll need to define a token value, and set that inside the Jenkins configuration for the SonarQube instance.
Although we don't do it this way in our builds, I believe if you call the "waitForQualityGate" step INSIDE the "withSonarQubeEnv" step, that will put the proper authentication token into the environment variable so "waitForQualityGate" can see it.
It's very handy to run a "sh" step, running the "env" command line, so you can see what variables are set in the environment at any particular time.
It's also good to read the "sonar-scanner" reference, which talks about these steps, at https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-jenkins/#AnalyzingwithSonarQubeScannerforJenkins-AnalyzinginaJenkinspipeline .
use this
withSonarQubeEnv(credentialsId: 'your token')

SonarQube Sonar.exclusions parameter is not working from jenkins and from SonarQube server

sonar.exclusions parameter is not working for Sonarqube, the sonar.exclusions parameter defined in Jenkins or project setting in SonarQube Server it is not taking effect and scanning all files.
I want to exclude CSS,JS and HTML file scanning from the project for that I defined
sonar.exclusions=**/*.css, **/*.js ,**/*.html
also defined the path with root path with Jenkins workspace like
sonar.exclusions=$WORKSPACE/src/**/*.css, $WORKSPACE/src/**/*.js
still no positive result .
Also defined exclusions in sonarQube sever also
Software Stack
SonarQube:7.9.4-community
Jenkins: 2.235.1
Jenkins-plugin: SonarQubeScanner for Jenkins 2.11
SonarQube Scanner:- 3.0.0.702
The Jenkins console output is the following . what mistake I am making here can someone guide me?
Dsonar.coverage.jacoco.xmlReportPaths=/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/build/reports/jacoco/test/jacocoTestReport.xml
Dsonar.sources=/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/src
Dsonar.surefire.reportsPath=/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/
build/test-results/test "-Dsonar.exclusions=**/*.css, **/*.js , **/*.html" -Dsonar.projectVersion=Octane-137020-SonarQube-Integrations -
Dsonar.java.binaries=/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/build/c
lasses -Dsonar.projectKey=LEMS_X_Exclude -
Dsonar.junit.reportPaths=/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/bui
ld/test-results/test
Dsonar.projectBaseDir=/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA
INFO: Scanner configuration file: /opt/cloudhost/apps/.jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQubeScanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.0.0.702
INFO: Java 1.8.0_252 Oracle Corporation (64-bit)
INFO: Linux 3.10.0-1127.10.1.el7.x86_64 amd64
INFO: User cache: /home/stlpdapi/.sonar/cache
INFO: SonarQube server 7.9.4
INFO: Default locale: "en_US", source code encoding: "UTF-8"
WARN: SonarScanner will require Java 11 to run starting in SonarQube 8.x
INFO: Load global settings
INFO: Load global settings (done) | time=119ms
INFO: Server id: E2281BAA-AXPWxgc9dGdpV1spT8iU
INFO: User cache: /home/stlpdapi/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=79ms
INFO: Load/download plugins (done) | time=134ms
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=3ms
INFO: Project key: LEMS_X_Exclude
INFO: Base dir: /opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA
INFO: Working dir: /opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/.scannerwork
INFO: Load project settings for component key: 'LEMS_X_Exclude'
INFO: Load project settings for component key: 'LEMS_X_Exclude' (done) | time=22ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=75ms
INFO: Detected Jenkins
INFO: Load active rules
INFO: Load active rules (done) | time=747ms
INFO: Indexing files...
INFO: Project configuration:
INFO: Excluded sources: **/*.css, **/*.js, **/*.html
INFO: Load project repositories
INFO: Load project repositories (done) | time=44ms
INFO: 1221 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for css: Sonar way
INFO: Quality profile for java: Sonar way
INFO: Quality profile for jsp: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: ------------- Run sensors on module LEMS_X_Exclude
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=25ms
INFO: Sensor JavaSquidSensor [java]
INFO: Configured Java source version (sonar.java.source): none
INFO: JavaClasspath initialization
WARN: Bytecode of dependencies was not provided for analysis of source files, you might end up with less precise results. Bytecode can be provided using sonar.java.libraries property.
INFO: JavaClasspath initialization (done) | time=12ms
INFO: JavaTestClasspath initialization
INFO: JavaTestClasspath initialization (done) | time=2ms
INFO: Java Main Files AST scan
INFO: 405 source files to be analyzed
INFO: 28/405 files analyzed, current file: src/main/java/com/mf/pdapi/orm/pojo/SoftwareLicenseStructure.java
INFO: 100/405 files analyzed, current file: src/main/java/com/mf/pdapi/services/pdapi/mappers/response/APGetEntitlementResponseMapper.java
INFO: 168/405 files analyzed, current file: src/main/java/com/mf/pdapi/web/controller/IndexController.java
INFO: 206/405 files analyzed, current file: src/main/java/com/mf/pdapi/web/controller/licensePanination/LicenseController.java
INFO: 258/405 files analyzed, current file: src/main/java/com/mf/pdapi/web/models/ProductVO.java
WARN: Invalid character encountered in file /opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/src/test/java/com/mf/pdapi/services/utils/SecurityHelperUtilTest.java at line 34 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: 405/405 source files have been analyzed
INFO: Java Main Files AST scan (done) | time=57784ms
INFO: Java Test Files AST scan
INFO: 0 source files to be analyzed
INFO: Java Test Files AST scan (done) | time=2ms
INFO: 0/0 source files have been analyzed
INFO: Sensor JavaSquidSensor [java] (done) | time=58443ms
INFO: Sensor SonarCSS Metrics [cssfamily]
INFO: Sensor SonarCSS Metrics [cssfamily] (done) | time=125ms
INFO: Sensor SonarCSS Rules [cssfamily]
ERROR: CSS rules were not executed. Error when running: 'node -v'. Is Node.js available during analysis?
org.sonarsource.nodejs.NodeCommandException: Error when running: 'node -v'. Is Node.js available during analysis?
at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:83)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.getVersion(NodeCommandBuilderImpl.java:196)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(NodeCommandBuilderImpl.java:169)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:144)
at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.initNodeCommand(CssAnalyzerBridgeServer.java:133)
at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.startServer(CssAnalyzerBridgeServer.java:101)
at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.startServerLazily(CssAnalyzerBridgeServer.java:153)
at org.sonar.css.plugin.CssRuleSensor.execute(CssRuleSensor.java:99)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
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.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.executeTask(Batch.java:99)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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:233)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.io.IOException: Cannot run program "node": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at org.sonarsource.nodejs.NodeCommand$ProcessWrapperImpl.start(NodeCommand.java:175)
at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:79)
... 37 common frames omitted
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 39 common frames omitted
INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=938ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=253ms
INFO: Sensor SurefireSensor [java]
INFO: parsing [/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/build/test-results/test]
INFO: Sensor SurefireSensor [java] (done) | time=35ms
INFO: Sensor JaCoCoSensor [java]
INFO: Sensor JaCoCoSensor [java] (done) | time=1ms
INFO: Sensor JavaXmlSensor [java]
INFO: 41 source files to be analyzed
INFO: Sensor JavaXmlSensor [java] (done) | time=526ms
INFO: Sensor HTML [web]
INFO: 41/41 source files have been analyzed
INFO: Sensor HTML [web] (done) | time=1841ms
INFO: Sensor XML Sensor [xml]
INFO: 52 source files to be analyzed
INFO: Sensor XML Sensor [xml] (done) | time=562ms
INFO: 52/52 source files have been analyzed
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=22ms
INFO: Sensor Java CPD Block Indexer
INFO: Sensor Java CPD Block Indexer (done) | time=640ms
INFO: 78 files had no CPD blocks
INFO: Calculating CPD for 427 files
INFO: CPD calculation finished
INFO: Analysis report generated in 378ms, dir size=9 MB
INFO: Analysis report compressed in 1574ms, zip size=3 MB
INFO: Analysis report uploaded in 263ms
The error is:
ERROR: CSS rules were not executed. Error when running: 'node -v'. Is Node.js available during analysis?
It means what you do not have nodejs installed. Just configure it in jenkins global tools menu, add it to your job and run it again.

SonarQube Scanner not sending result to SonarQube after executing in a Jenkins job

After SonarQube Scanner was executed by a Jenkins job, the analysis result is not being uploaded to the SonarQube server:
00:15:23.616 INFO: ANALYSIS SUCCESSFUL
00:15:23.621 DEBUG: Post-jobs : GitHub Pull Request Issue Publisher (wrapped)
00:15:23.621 INFO: Executing post-job GitHub Pull Request Issue Publisher (wrapped)
In one of my other Jenkins jobs, the result is actually uploaded to SonarQube with this log which is not found for above case:
INFO: Sensor CPD Block Indexer (done) | time=0ms
INFO: 20 files had no CPD blocks
INFO: Calculating CPD for 46 files
INFO: CPD calculation finished
INFO: Analysis report generated in 312ms, dir size=1 MB
INFO: Analysis reports compressed in 227ms, zip size=561 KB
INFO: Analysis report uploaded in 256ms
Is there anything I can do to fix this?

Sonarqube Source error in jenkins build

I am trying to analyze my project with sonarqube scanner in Jenkins. However when I'm building job it's always reporting some kind of an error, more exactly:
INFO: Option -e/--errors is no longer supported and will be ignored
INFO: Scanner configuration file: /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarScanner1/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.0.3.778
INFO: Java 1.8.0_151 Oracle Corporation (64-bit)
INFO: Linux 4.9.60-linuxkit-aufs amd64
INFO: User cache: /var/jenkins_home/.sonar/cache
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=232ms
INFO: Server id: AWEptYvpPRWpK4xbT0G4
INFO: User cache: /var/jenkins_home/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=124ms
INFO: SonarQube server 6.7.1
INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Process project properties
ERROR: Invalid value of sonar.sources for test
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 3.218s
INFO: Final Memory: 42M/114M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: The folder 'polacpat/Documents/Jenkins2/workspace/SonarScanningTestProject/src/test' does not exist for 'test' (base directory = /var/jenkins_home/workspace/SonarScanningTestProject)
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE
Those are my Sonarqube analysis properties
AnalysisProperties
This is location of my project, it's automatically created because code is from gitlab...
Project Location
Now I don't really understand how does this work and how should I configure it. I have added the same name to a new sonarqube project and also sonarqube project key I have created within a sonarqube which is connected with a jenkins to those analyse properties in here, I don't understand how exactly does this works...
Updated folder:
Wrong Folder Being Analysed
Updated second error log after trying to set: sonar.sources=./src or
sonar.sources=./src/main
11:19:28.650 ERROR: Error during SonarQube Scanner execution
org.sonar.squidbridge.api.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property
at org.sonar.java.JavaClasspath.init(JavaClasspath.java:59)
at org.sonar.java.AbstractJavaClasspath.getElements(AbstractJavaClasspath.java:281)
at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:141)
at org.sonar.java.JavaSquid.<init>(JavaSquid.java:83)
at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:83)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:180)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:288)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:283)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:261)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:111)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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:233)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
11:19:28.651 DEBUG: Execution getVersion
11:19:28.656 DEBUG: Execution stop
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE
"Invalid value of sonar.sources for test"
sonar.sources must be relative to worskspace
sonar.sources=./src/test
And
Please provide compiled classes of your project with sonar.java.binaries property
means you need set sonar.java.binaries pointing to binaries
sonar.java.binaries=target/classes
See sonar paramenters

Sonarqube not reporting results back to Jenkins and Gerrit

Context:
Right now I have a Jenkins freestyle job that is triggered by some Gerrit events. When it is triggered, it downloads the changes and runs a Sonarqube Analysis on them. After the analysis is done, it is supposed to post comments on Gerrit detailing the results.
Unfortunately, no matter what the result of the Sonarqube analysis, the comment always says "sonarqube violations have not been found."
Some pictures:
Jenkins Freestyle Job Configuration:
Versions:
Jenkins v2.46.2
Gerrit Trigger Plugin v.2.24.0
Sonar Gerrit Plugin v2.0
Sonarqube Scanner for Jenkins Plugin v2.6.1
Sonarqube v6.3.1
Gerrit v2.13.5
Output from the Jenkins console:
Unpacking https://repo1.maven.org/maven2/org/sonarsource/scanner/cli/sonar-scanner-cli/3.0.3.778/sonar-scanner-cli-3.0.3.778.zip to /var/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonar on ubuntu-graphical
[osstp-ci] $ /var/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonar/bin/sonar-scanner -e -Dsonar.host.url=<ip_address>:9000 -Dsonar.projectName=osstp-work -Dsonar.issuesReport.json.enable=true -Dsonar.report.export.path=sonar-report.json -Dsonar.analysis.mode=preview -Dsonar.projectKey=org.vmware:osstpmgt -Dsonar.inclusions=**/*.py -Dsonar.host.url=http://10.20.96.87:9000 -Dsonar.sources=. -Dsonar.projectBaseDir=/var/jenkins/workspace/osstp-ci
INFO: Option -e/--errors is no longer supported and will be ignored
INFO: Scanner configuration file: /var/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonar/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.0.3.778
INFO: Java 1.8.0_131 Oracle Corporation (64-bit)
INFO: Linux 4.8.0-36-generic amd64
INFO: User cache: /home/tgong/.sonar/cache
INFO: Load global settings
INFO: Load global settings (done) | time=160ms
INFO: User cache: /home/tgong/.sonar/cache
INFO: Exclude plugins: devcockpit, ldap, authgithub, authbitbucket, pdfreport, authaad, googleanalytics, governance
INFO: Load plugins index
INFO: Load plugins index (done) | time=10ms
INFO: Download sonar-csharp-plugin-5.7.0.612.jar
INFO: Download sonar-python-plugin-1.7.0.1195.jar
INFO: Download sonar-java-plugin-4.5.0.8398.jar
INFO: Download sonar-flex-plugin-2.3.jar
INFO: Download sonar-scm-git-plugin-1.2.jar
INFO: Download sonar-php-plugin-2.9.2.1744.jar
INFO: Download sonar-scm-svn-plugin-1.4.0.522.jar
INFO: Download sonar-javascript-plugin-2.20.0.4207.jar
INFO: SonarQube server 6.3.1
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=217ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=66ms
INFO: Load active rules
INFO: Load active rules (done) | time=1693ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=141ms
INFO: Issues mode
INFO: Scanning only changed files
INFO: Project key: org.vmware:osstpmgt
INFO: ------------- Scan osstp-work
INFO: Load server rules
INFO: Load server rules (done) | time=68ms
INFO: Base dir: /var/jenkins/workspace/osstp-ci
INFO: Working dir: /var/jenkins/workspace/osstp-ci/.scannerwork
INFO: Source paths: .
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: Included sources:
INFO: **/*.py
WARN: Not indexing due to symlink loop: /var/jenkins/workspace/osstp-ci/www/scotzilla
INFO: 717 files indexed
INFO: 2093 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for py: Sonar way
INFO: Sensor NoSonar Sensor [php]
INFO: Sensor NoSonar Sensor [php] (done) | time=1ms
INFO: Sensor Coverage Report Import [csharp]
INFO: Sensor Coverage Report Import [csharp] (done) | time=1ms
INFO: Sensor Coverage Report Import [csharp]
INFO: Sensor Coverage Report Import [csharp] (done) | time=0ms
INFO: Sensor Unit Test Results Import [csharp]
INFO: Sensor Unit Test Results Import [csharp] (done) | time=1ms
INFO: Sensor XmlFileSensor [java]
INFO: Sensor XmlFileSensor [java] (done) | time=7ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=8ms
INFO: Load server issues
INFO: Load server issues (done) | time=1053ms
INFO: Performing issue tracking
INFO: 813/813 components tracked
INFO: Export issues to /var/jenkins/workspace/osstp-ci/.scannerwork/sonar-report.json
INFO: ANALYSIS SUCCESSFUL
INFO: Task total time: 11.610 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 17.577s
INFO: Final Memory: 46M/114M
INFO: ------------------------------------------------------------------------
Getting Sonar Report from: /var/jenkins/workspace/osstp-ci/.scannerwork/sonar-report.json
Report has loaded and contains 1492 issues
Connected to Gerrit: server name: Gerrit. Change Number: 32, PatchSetNumber: 1
Review has been sent
Finished: SUCCESS
Not sure if you already resolved this, but your "Project Settings" entry is empty and there was a recent fix (Jan 2018 - JENKINS-43730) that addresses what may have caused your issue: https://wiki.jenkins.io/display/JENKINS/Sonar+Gerrit#SonarGerrit-Version2.1(6Jan2018)
Try to set the following:
1) Build > Execute SonarQube Scanner > Analysis properties
sonar.report.export.path=sonar-report.json
2) Post-build Actions > Post SonarQube issues as Gerrit comments > Project Settings
SonarQube report path = .sonar/sonar-report.json
Seems like your user.dir property is not set. Set it to the location where git downloads the code (most probably in $WORKSPACE)
so, include this user.dir=$WORKSPACE with the other analysis parameters.

Resources