I am fairly new with jenkins and sonar scanner. I have created a simple hello world gradle project in Intellij. After that was done, i added the Jenkinsfile to the root folder of the project and started working on it. When i try to build it in jenkins, i get an error message looking like this:
05:57:51.485 INFO: Scanner configuration file: /usr/lib/sonar-scanner/conf/sonar-scanner.properties
05:57:51.491 INFO: Project root configuration file: /root/src/sonar-project.properties
05:57:51.506 INFO: SonarQube Scanner 3.3.0.1492
05:57:51.506 INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
05:57:51.506 INFO: Linux 3.10.0-957.5.1.el7.x86_64 amd64
05:57:51.702 DEBUG: keyStore is :
05:57:51.702 DEBUG: keyStore type is : jks
05:57:51.702 DEBUG: keyStore provider is :
05:57:51.702 DEBUG: init keystore
05:57:51.703 DEBUG: init keymanager of type SunX509
05:57:51.877 DEBUG: Create: /root/.sonar/cache
05:57:51.879 INFO: User cache: /root/.sonar/cache
05:57:51.879 DEBUG: Create: /root/.sonar/cache/_tmp
05:57:51.881 DEBUG: Extract sonar-scanner-api-batch in temp...
05:57:51.889 DEBUG: Get bootstrap index...
05:57:51.889 DEBUG: Download: http://10.221.4.33:9000/batch/index
05:57:51.968 DEBUG: Get bootstrap completed
05:57:51.986 DEBUG: Download http://10.221.4.33:9000/batch/file?name=sonar-scanner-engine-shaded-7.7-all.jar to /root/.sonar/cache/_tmp/fileCache3570509839777067796.tmp
05:57:52.323 DEBUG: Create isolated classloader...
05:57:52.333 DEBUG: Start temp cleaning...
05:57:52.338 DEBUG: Temp cleaning done
05:57:52.338 DEBUG: Execution getVersion
05:57:52.345 INFO: SonarQube server 7.7.0
05:57:52.346 DEBUG: Execution execute
05:57:52.801 INFO: Load global settings
05:57:52.879 DEBUG: GET 200 http://10.221.4.33:9000/api/settings/values.protobuf | time=58ms
05:57:52.936 INFO: Load global settings (done) | time=138ms
05:57:52.944 INFO: Server id: C9A263D1-AWnZoCq1phaxFFDSMo0l
05:57:52.966 DEBUG: Create : /root/.sonar/_tmp
05:57:52.967 INFO: User cache: /root/.sonar/cache
05:57:52.971 INFO: Load/download plugins
05:57:52.972 INFO: Load plugins index
05:57:52.981 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/installed | time=9ms
05:57:53.025 INFO: Load plugins index (done) | time=52ms
05:57:53.027 DEBUG: Download plugin 'scmgit' to '/root/.sonar/_tmp/fileCache4395394311979981807.tmp'
05:57:53.034 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=scmgit&acceptCompressions=pack200 | time=7ms
05:57:53.112 DEBUG: Download plugin 'jacoco' to '/root/.sonar/_tmp/fileCache6933684684880586527.tmp'
05:57:53.118 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=jacoco&acceptCompressions=pack200 | time=6ms
05:57:53.119 DEBUG: Download plugin 'ldap' to '/root/.sonar/_tmp/fileCache7133022802065402857.tmp'
05:57:53.128 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=ldap&acceptCompressions=pack200 | time=8ms
05:57:53.136 DEBUG: Download plugin 'csharp' to '/root/.sonar/_tmp/fileCache9082420825692938062.tmp'
05:57:53.150 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=csharp&acceptCompressions=pack200 | time=13ms
05:57:53.241 DEBUG: Download plugin 'cssfamily' to '/root/.sonar/_tmp/fileCache293189218006487968.tmp'
05:57:53.246 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=cssfamily&acceptCompressions=pack200 | time=5ms
05:57:53.301 DEBUG: Download plugin 'clojure' to '/root/.sonar/_tmp/fileCache948669080401350606.tmp'
05:57:53.307 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=clojure&acceptCompressions=pack200 | time=6ms
05:57:53.379 DEBUG: Download plugin 'flex' to '/root/.sonar/_tmp/fileCache3889788857842376851.tmp'
05:57:53.386 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=flex&acceptCompressions=pack200 | time=7ms
05:57:53.401 DEBUG: Download plugin 'go' to '/root/.sonar/_tmp/fileCache4205858474210720715.tmp'
05:57:53.408 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=go&acceptCompressions=pack200 | time=7ms
05:57:53.462 DEBUG: Download plugin 'web' to '/root/.sonar/_tmp/fileCache783608628579300027.tmp'
05:57:53.470 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=web&acceptCompressions=pack200 | time=8ms
05:57:53.502 DEBUG: Download plugin 'javascript' to '/root/.sonar/_tmp/fileCache895874836559468181.tmp'
05:57:53.523 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=javascript&acceptCompressions=pack200 | time=20ms
05:57:53.641 DEBUG: Download plugin 'java' to '/root/.sonar/_tmp/fileCache2653809152725468294.tmp'
05:57:53.649 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=java&acceptCompressions=pack200 | time=8ms
05:57:53.724 DEBUG: Download plugin 'kotlin' to '/root/.sonar/_tmp/fileCache4849792320171587582.tmp'
05:57:53.731 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=kotlin&acceptCompressions=pack200 | time=7ms
05:57:53.819 DEBUG: Download plugin 'php' to '/root/.sonar/_tmp/fileCache6204606293784138971.tmp'
05:57:53.826 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=php&acceptCompressions=pack200 | time=7ms
05:57:53.877 DEBUG: Download plugin 'python' to '/root/.sonar/_tmp/fileCache288964667021647401.tmp'
05:57:53.885 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=python&acceptCompressions=pack200 | time=7ms
05:57:53.910 DEBUG: Download plugin 'ruby' to '/root/.sonar/_tmp/fileCache5281102871587928818.tmp'
05:57:53.915 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=ruby&acceptCompressions=pack200 | time=4ms
05:57:53.993 DEBUG: Download plugin 'sonarscala' to '/root/.sonar/_tmp/fileCache1960676723457785292.tmp'
05:57:53.998 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=sonarscala&acceptCompressions=pack200 | time=5ms
05:57:54.070 DEBUG: Download plugin 'typescript' to '/root/.sonar/_tmp/fileCache7183740303261272847.tmp'
05:57:54.076 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=typescript&acceptCompressions=pack200 | time=6ms
05:57:54.095 DEBUG: Download plugin 'vbnet' to '/root/.sonar/_tmp/fileCache7315453031927695364.tmp'
05:57:54.100 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=vbnet&acceptCompressions=pack200 | time=5ms
05:57:54.170 DEBUG: Download plugin 'xml' to '/root/.sonar/_tmp/fileCache226747213883935028.tmp'
05:57:54.177 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=xml&acceptCompressions=pack200 | time=6ms
05:57:54.198 DEBUG: Download plugin 'scmsvn' to '/root/.sonar/_tmp/fileCache1337467676129254645.tmp'
05:57:54.203 DEBUG: GET 200 http://10.221.4.33:9000/api/plugins/download?plugin=scmsvn&acceptCompressions=pack200 | time=5ms
05:57:54.257 INFO: Load/download plugins (done) | time=1286ms
05:57:54.464 DEBUG: Plugins:
05:57:54.464 DEBUG: * SonarPython 1.13.0.2922 (python)
05:57:54.464 DEBUG: * SonarCSS 1.0.3.724 (cssfamily)
05:57:54.464 DEBUG: * SonarClojure 1.8.1 (clojure)
05:57:54.464 DEBUG: * JaCoCo 1.0.1.143 (jacoco)
05:57:54.464 DEBUG: * SonarGo 1.1.0.1612 (go)
05:57:54.464 DEBUG: * SonarKotlin 1.5.0.315 (kotlin)
05:57:54.464 DEBUG: * Svn 1.9.0.1295 (scmsvn)
05:57:54.464 DEBUG: * SonarJS 5.1.1.7506 (javascript)
05:57:54.464 DEBUG: * SonarRuby 1.5.0.315 (ruby)
05:57:54.465 DEBUG: * SonarScala 1.5.0.315 (sonarscala)
05:57:54.465 DEBUG: * SonarC# 7.14.0.8411 (csharp)
05:57:54.465 DEBUG: * SonarJava 5.12.1.17771 (java)
05:57:54.465 DEBUG: * LDAP 2.2.0.608 (ldap)
05:57:54.465 DEBUG: * SonarHTML 3.1.0.1615 (web)
05:57:54.465 DEBUG: * Git 1.8.0.1574 (scmgit)
05:57:54.465 DEBUG: * SonarFlex 2.4.0.1222 (flex)
05:57:54.465 DEBUG: * SonarXML 2.0.1.2020 (xml)
05:57:54.465 DEBUG: * SonarPHP 3.0.0.4537 (php)
05:57:54.465 DEBUG: * SonarTS 1.9.0.3766 (typescript)
05:57:54.465 DEBUG: * SonarVB 7.14.0.8411 (vbnet)
05:57:54.493 INFO: ------------------------------------------------------------------------
05:57:54.493 INFO: EXECUTION FAILURE
05:57:54.493 INFO: ------------------------------------------------------------------------
05:57:54.493 INFO: Total time: 3.042s
05:57:54.591 INFO: Final Memory: 9M/597M
05:57:54.591 INFO: ------------------------------------------------------------------------
05:57:54.591 ERROR: Error during SonarQube Scanner execution
05:57:54.591 ERROR: Tasks support was removed in SonarQube 7.6.
I have tried searching for the error (Tasks support was removed in Sonarqube 7.6) which really havent helped me at all so far. I've tried seperate ways of constructing the Jenkinsfile but seems to be no luck at all.
This is my jenkinsfile:
pipeline {
agent any
stages {
stage('List folder') {
steps {
sh 'ls'
}
}
stage('Make folder for docker') {
steps {
sh 'docker run -v $(pwd):/root/src newtmitch/sonar-scanner sonar-scanner -X \
-Dsonar.host.url=http://XXXX:9000 \
-Dsonar.jdbc.url=jdbc:h2:tcp://sonarqube/sonar \
-Dsonar.projectKey=MyProjectKey \
-Dsonar.projectName="My Project Name" \
-Dsonar.projectVersion=1 \
-Dsonar.projectBaseDir=/root/src \
-Dsonar.sources=/root/src'
}
}
}
}
It seems to be able to get the right docker image from sonar scanner, but why is it failing afterwards?
The steps should be somewhat simple:
1. Get image.
2. Build Gradle project
3. Scan project code
4. Profit.
In case anyone runs into this, i solved it by removing "sonar-scanner -X" from the docker run command.
unsure why it changed anything but now it can analyze the project code correctly.
thanks
Related
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')
I am trying to learn the basics of sonarqube, I have set it up on my jenkins pipeline (which uses MSBuild to compile the project) and the set a step to execute SonarQube but after reading and watching a few tutorials and the documentation itself I think I got a bit lost as when my pipeline finishes executing I go to my SonarQube server and I my project says The main branch has no lines of code.. I get the following log when running the sonarqube step on my jenkins:
00:10:43.369 Injecting SonarQube environment variables using the configuration: SonarQube
[Pipeline] {
[Pipeline] bat
00:10:43.653
00:10:43.653 C:\Users\anton\.jenkins\workspace\Boston>C:\Users\anton\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\Sonnar_scanner\sonar-scanner-4.4.0.2170\bin\sonar-scanner.bat
00:10:43.653 INFO: Scanner configuration file: C:\Users\anton\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\Sonnar_scanner\sonar-scanner-4.4.0.2170\bin\..\conf\sonar-scanner.properties
00:10:43.653 INFO: Project root configuration file: NONE
00:10:43.653 INFO: SonarScanner 4.4.0.2170
00:10:43.653 INFO: Java 1.8.0_261 Oracle Corporation (64-bit)
00:10:43.653 INFO: Windows 10 10.0 amd64
00:10:44.230 INFO: User cache: C:\WINDOWS\system32\config\systemprofile\.sonar\cache
00:10:44.230 INFO: Scanner configuration file: C:\Users\anton\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\Sonnar_scanner\sonar-scanner-4.4.0.2170\bin\..\conf\sonar-scanner.properties
00:10:44.230 INFO: Project root configuration file: NONE
00:10:44.230 INFO: Analyzing on SonarQube server 8.5.1
00:10:44.230 INFO: Default locale: "es_ES", source code encoding: "UTF-8"
00:10:44.783 WARN: SonarScanner will require Java 11 to run starting in SonarQube 8.x
00:10:44.784 INFO: Load global settings
00:10:44.784 INFO: Load global settings (done) | time=40ms
00:10:44.784 INFO: Server id: BF41A1F2-AXWnoupqHjnRwWgEnmvK
00:10:44.784 INFO: User cache: C:\WINDOWS\system32\config\systemprofile\.sonar\cache
00:10:44.784 INFO: Load/download plugins
00:10:44.784 INFO: Load plugins index
00:10:44.784 INFO: Load plugins index (done) | time=26ms
00:10:44.784 INFO: Load/download plugins (done) | time=48ms
00:10:45.037 INFO: Process project properties
00:10:45.037 INFO: Process project properties (done) | time=6ms
00:10:45.037 INFO: Execute project builders
00:10:45.037 INFO: Execute project builders (done) | time=1ms
00:10:45.037 INFO: Project key: Boston
00:10:45.037 INFO: Base dir: C:\Users\anton\.jenkins\workspace\Boston
00:10:45.037 INFO: Working dir: C:\Users\anton\.jenkins\workspace\Boston\.scannerwork
00:10:45.301 INFO: Load project settings for component key: 'Boston'
00:10:45.301 INFO: Load project settings for component key: 'Boston' (done) | time=10ms
00:10:45.301 INFO: Load quality profiles
00:10:45.301 INFO: Load quality profiles (done) | time=27ms
00:10:45.301 INFO: Auto-configuring with CI 'Jenkins'
00:10:45.301 INFO: Load active rules
00:10:46.241 INFO: Load active rules (done) | time=787ms
00:10:46.241 INFO: Indexing files...
00:10:46.241 INFO: Project configuration:
00:10:46.241 INFO: 0 files indexed
00:10:46.241 INFO: ------------- Run sensors on module Boston
00:10:46.241 INFO: Load metrics repository
00:10:46.241 INFO: Load metrics repository (done) | time=12ms
00:10:46.807 INFO: Sensor CSS Rules [cssfamily]
00:10:46.807 INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
00:10:46.807 INFO: Sensor CSS Rules [cssfamily] (done) | time=1ms
00:10:46.807 INFO: Sensor JaCoCo XML Report Importer [jacoco]
00:10:46.807 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
00:10:46.807 INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
00:10:46.807 INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=1ms
00:10:46.807 INFO: Sensor C# Properties [csharp]
00:10:46.807 INFO: Sensor C# Properties [csharp] (done) | time=1ms
00:10:46.807 INFO: Sensor JavaXmlSensor [java]
00:10:46.807 INFO: Sensor JavaXmlSensor [java] (done) | time=0ms
00:10:46.807 INFO: Sensor VB.NET Properties [vbnet]
00:10:46.807 INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms
00:10:46.807 INFO: ------------- Run sensors on project
00:10:46.807 INFO: Sensor Zero Coverage Sensor
00:10:46.807 INFO: Sensor Zero Coverage Sensor (done) | time=0ms
00:10:46.807 INFO: SCM Publisher is disabled
00:10:46.807 INFO: CPD Executor Calculating CPD for 0 files
00:10:46.807 INFO: CPD Executor CPD calculation finished (done) | time=0ms
00:10:46.807 INFO: Analysis report generated in 48ms, dir size=82 KB
00:10:46.807 INFO: Analysis report compressed in 10ms, zip size=10 KB
00:10:47.060 INFO: Analysis report uploaded in 26ms
00:10:47.060 INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=Boston
00:10:47.060 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
00:10:47.060 INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AXWt8eSC9o0F9NdVJGJP
00:10:47.060 INFO: Executing post-job 'Final report'
00:10:47.060 INFO: Turn debug info on to get more details (sonar-scanner -X -Dsonar.verbose=true ...).
00:10:47.060 INFO: Analysis total time: 2.118 s
00:10:47.060 INFO: ------------------------------------------------------------------------
00:10:47.060 INFO: EXECUTION SUCCESS
00:10:47.060 INFO: ------------------------------------------------------------------------
00:10:47.060 INFO: Total time: 3.274s
00:10:47.060 INFO: Final Memory: 21M/549M
00:10:47.060 INFO: ------------------------------------------------------------------------
[Pipeline] }
[Pipeline] // withSonarQubeEnv
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // timestamps
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
and I think the main issue is the line where it says Project root configuration file: NONE I have created a sonar-project.properties file in the root folder of my project and it has the following configuration:
sonar.projectKey=Boston
sonar.projectName=Boston
sonar.dotnet.visualStudio.solution=Age3DE.sln
sonar.scm.disabled=true
sonar.sources=./Source
sonar.language=c++
sonar.sourceEncoding=UTF-8
But yet I cannot make it work. I do not know what I am doing wrong, should the sonar-project.properties be set anywhere else?
If the source files are present in Sources directory, then your sonar.sources should be like this
sonar.sources=**/Sources/*
Or
sonar.sources=Sources/*
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.
Please help me How to resolve this issue -
Getting Error while Sending Code from Jenkins to SonarQube.
git rev-list --no-walk 0070e5865725fdacc46d8444385e337eb9e6c4c8 # timeout=10
Unpacking https://repo1.maven.org/maven2/org/sonarsource/scanner/cli/sonar-scanner-cli/4.2.0.1873/sonar-scanner-cli-4.2.0.1873.zip to /jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/ADOP_Sonar on 00a4ea1e
[Generali] $ /jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/ADOP_Sonar/bin/sonar-scanner -X -Dsonar.host.url=https://alm.accenture.com/sonar -Dsonar.language=java "-Dsonar.projectName=Connected Vehicle Platform Sonar" -Dsonar.sourceEncoding=UTF-8 -Dsonar.projectKey=adop:CVPIFBNE:cvp -Dsonar.java.binaries=target/classes -Dsonar.sources=src/main/java -Dsonar.projectBaseDir=C:/Jenkins/workspace/Generali
14:30:02.030 INFO: Scanner configuration file: /jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/ADOP_Sonar/conf/sonar-scanner.properties
14:30:02.038 INFO: Project root configuration file: NONE
14:30:02.147 INFO: SonarQube Scanner 4.2.0.1873
14:30:02.147 INFO: Java 9 Oracle Corporation (64-bit)
14:30:02.147 INFO: Linux 3.10.0-957.12.2.el7.x86_64 amd64
14:30:02.147 INFO: SONAR_SCANNER_OPTS=-Dsonar.login=04bcf7a2d5c6a5d44d9763fd840e723cbc85bb7e
14:30:02.641 DEBUG: keyStore is :
14:30:02.642 DEBUG: keyStore type is : pkcs12
14:30:02.642 DEBUG: keyStore provider is :
14:30:02.642 DEBUG: init keystore
14:30:02.643 DEBUG: init keymanager of type SunX509
14:30:02.897 DEBUG: Create: /root/.sonar/cache
14:30:02.899 INFO: User cache: /root/.sonar/cache
14:30:02.899 DEBUG: Create: /root/.sonar/cache/_tmp
14:30:02.904 DEBUG: Extract sonar-scanner-api-batch in temp...
14:30:02.911 DEBUG: Get bootstrap index...
14:30:02.911 DEBUG: Download: https://alm.accenture.com/sonar/batch/index
14:30:03.208 DEBUG: Get bootstrap completed
14:30:03.215 DEBUG: Download https://alm.accenture.com/sonar/batch/file?name=scanner-enterprise-7.9.1-all.jar to /root/.sonar/cache/_tmp/fileCache9893797395313049837.tmp
14:30:05.187 DEBUG: Create isolated classloader...
14:30:05.215 DEBUG: Start temp cleaning...
14:30:05.221 DEBUG: Temp cleaning done
14:30:05.222 DEBUG: Execution getVersion
14:30:05.237 INFO: SonarQube server 7.9.1
14:30:05.238 INFO: Default locale: "en", source code encoding: "UTF-8"
14:30:05.240 INFO: ------------------------------------------------------------------------
14:30:05.240 INFO: EXECUTION FAILURE
14:30:05.240 INFO: ------------------------------------------------------------------------
14:30:05.241 INFO: Total time: 3.298s
14:30:05.291 INFO: Final Memory: 3M/14M
14:30:05.291 INFO: ------------------------------------------------------------------------
14:30:05.291 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Project home must be an existing directory: /C:/Jenkins/workspace/Generali/C:/Jenkins/workspace/Generali
at org.sonarsource.scanner.api.Dirs.initProjectDirs(Dirs.java:51)
at org.sonarsource.scanner.api.Dirs.init(Dirs.java:41)
at org.sonarsource.scanner.api.EmbeddedScanner.initAnalysisProperties(EmbeddedScanner.java:158)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
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)
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE
I had a similar issue:
ERROR: Error during SonarQube Scanner execution
ERROR: Project home must be an existing directory: C:\Windows\system32\config\...blah blah blah
I initially set my sonar.projectBaseDir by copying and pasting the path from File Explorer. The issue was Windows uses backslashes for paths. Once I switched them to forward slashes, the issue was fixed for me.
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.