SonarQube hanging at Load project settings - sonarqube

I have a project that is hanging when it gets to "Load project settings"
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: /var/lib/jenkins/jobs/project_Sonar/workspace/target/sonar
INFO: SonarQube Server 5.1
[INFO] [12:35:43.126] Load global repositories
[INFO] [12:35:43.437] Load global repositories (done) | time=315ms
[INFO] [12:35:43.443] Server id: 20150416114227
[INFO] [12:35:43.446] User cache: /var/lib/jenkins/.sonar/cache
[INFO] [12:35:43.467] Install plugins
[INFO] [12:35:46.426] Install JDBC driver
[INFO] [12:35:46.443] Create JDBC datasource for jdbc:mysql://192.16.16.116:3306/sonar02?autoReconnect=true&useUnicode=true&characterEncoding=utf8
[INFO] [12:35:49.494] Initializing Hibernate
[INFO] [12:35:53.844] Load project repositories
[INFO] [12:35:54.217] Load project repositories (done) | time=372ms
[INFO] [12:35:54.217] Load project settings
Any recommendations on troubleshooting would be appreciated.
The last line of access.log is
[16/Apr/2015:12:35:54 -0600] "GET /batch/project?key=products-project-aggregator&preview=false HTTP/1.1" 200 - "-" "SonarQube Maven/3.2.2"
and nothing related in sonar.log

Related

SonarQube "The main branch has no lines of code." issue while Jenkins says analysis is successful

I have a maven project which I want to build and scan in Jenkins. It scans the code with SonarQube scanner and uploads the results to my SonarQube server. Jenkins says that everything went successful, however when I then have a look at SonarQube, I see this...
The console output in Jenkins looks like this: (note: I only pasted the last part, not the entire output)
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) # authentication-service ---
[INFO] Building jar: /var/jenkins_home/workspace/AuthenticationService/microservices/authentication-service/target/authentication-service-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.2.4.RELEASE:repackage (repackage) # authentication-service ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) # authentication-service ---
[INFO] Installing /var/jenkins_home/workspace/AuthenticationService/microservices/authentication-service/target/authentication-service-0.0.1-SNAPSHOT.jar to /var/jenkins_home/.m2/repository/com/authentication/microservice/authentication-service/0.0.1-SNAPSHOT/authentication-service-0.0.1-SNAPSHOT.jar
[INFO] Installing /var/jenkins_home/workspace/AuthenticationService/microservices/authentication-service/pom.xml to /var/jenkins_home/.m2/repository/com/authentication/microservice/authentication-service/0.0.1-SNAPSHOT/authentication-service-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # authentication-service ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # authentication-service ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 14 source files to /var/jenkins_home/workspace/AuthenticationService/microservices/authentication-service/target/classes
[INFO] /var/jenkins_home/workspace/AuthenticationService/microservices/authentication-service/src/main/java/com/authentication/microservice/authenticationservice/helpers/JsonWebTokenGenerator.java: /var/jenkins_home/workspace/AuthenticationService/microservices/authentication-service/src/main/java/com/authentication/microservice/authenticationservice/helpers/JsonWebTokenGenerator.java uses or overrides a deprecated API.
[INFO] /var/jenkins_home/workspace/AuthenticationService/microservices/authentication-service/src/main/java/com/authentication/microservice/authenticationservice/helpers/JsonWebTokenGenerator.java: Recompile with -Xlint:deprecation for details.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:00 min
[INFO] Finished at: 2020-05-22T18:41:07Z
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /var/jenkins_home/workspace/AuthenticationService/microservices/authentication-service/pom.xml to com.authentication.microservice/authentication-service/0.0.1-SNAPSHOT/authentication-service-0.0.1-SNAPSHOT.pom
channel stopped
[AuthenticationService] $ /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner/bin/sonar-scanner -Dsonar.host.url=http://35.195.88.51 ******** -Dsonar.projectName=AuthenticationService -Dsonar.projectVersion=1.0 -Dsonar.projectKey=com.authentication.microservice:authentication-service -Dsonar.sources=/var/jenkins_home/workspace/AuthenticationService/microservices/authentication-service/target -Dsonar.projectBaseDir=/var/jenkins_home/workspace/AuthenticationService
INFO: Scanner configuration file: /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.3.0.2102
INFO: Java 1.8.0_221 Oracle Corporation (64-bit)
INFO: Linux 4.14.138+ amd64
INFO: User cache: /var/jenkins_home/.sonar/cache
INFO: Scanner configuration file: /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: Analyzing on SonarQube server 7.9.1
INFO: Default locale: "en_US", source code encoding: "US-ASCII" (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=97ms
INFO: Server id: A7EE8CF2-AXI9JaBwRGaHU4KxYo1w
INFO: User cache: /var/jenkins_home/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=58ms
INFO: Load/download plugins (done) | time=117ms
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=11ms
INFO: Project key: com.authentication.microservice:authentication-service
INFO: Base dir: /var/jenkins_home/workspace/AuthenticationService
INFO: Working dir: /var/jenkins_home/workspace/AuthenticationService/.scannerwork
INFO: Load project settings for component key: 'com.authentication.microservice:authentication-service'
INFO: Load project settings for component key: 'com.authentication.microservice:authentication-service' (done) | time=18ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=57ms
INFO: Detected Jenkins
INFO: Load active rules
INFO: Load active rules (done) | time=724ms
INFO: Indexing files...
INFO: Project configuration:
INFO: 0 files indexed
INFO: 0 files ignored because of scm ignore settings
INFO: ------------- Run sensors on module AuthenticationService
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=41ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=11ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=1ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=0ms
INFO: Calculating CPD for 0 files
INFO: CPD calculation finished
INFO: Analysis report generated in 174ms, dir size=72 KB
INFO: Analysis report compressed in 16ms, zip size=9 KB
INFO: Analysis report uploaded in 37ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://35.195.88.51/dashboard?id=com.authentication.microservice%3Aauthentication-service
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://35.195.88.51/api/ce/task?id=AXI9sHtMRGaHU4KxYq-d
INFO: Analysis total time: 5.800 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 7.538s
INFO: Final Memory: 13M/33M
INFO: ------------------------------------------------------------------------
Finished: SUCCESS
The SonarQube scanner configuration for this job looks like this:
I have tried different paths for the sonar.sources property, but nothing works. It gives the same result, or gives an error in the Jenkins build.
I am really stuck now, it took me a whole day and I have made no progress. I'd be very grateful if someone could help me, thanks!
Edit: here is the last part of the output when I switch /target for /src in the sonar.sources property:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:02 min
[INFO] Finished at: 2020-05-23T21:34:12Z
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /var/jenkins_home/workspace/AuthenticationService/microservices/authentication-service/pom.xml to com.authentication.microservice/authentication-service/0.0.1-SNAPSHOT/authentication-service-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving /var/jenkins_home/workspace/AuthenticationService/microservices/authentication-service/target/authentication-service-0.0.1-SNAPSHOT.jar to com.authentication.microservice/authentication-service/0.0.1-SNAPSHOT/authentication-service-0.0.1-SNAPSHOT.jar
channel stopped
[AuthenticationService] $ /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner/bin/sonar-scanner -Dsonar.host.url=http://35.195.88.51 ******** -Dsonar.projectName=AuthenticationService -Dsonar.projectVersion=1.0 -Dsonar.projectKey=com.authentication.microservice:authentication-service -Dsonar.sources=/var/jenkins_home/workspace/AuthenticationService/microservices/authentication-service/src -Dsonar.projectBaseDir=/var/jenkins_home/workspace/AuthenticationService
INFO: Scanner configuration file: /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.3.0.2102
INFO: Java 1.8.0_221 Oracle Corporation (64-bit)
INFO: Linux 4.14.138+ amd64
INFO: User cache: /var/jenkins_home/.sonar/cache
INFO: Scanner configuration file: /var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: Analyzing on SonarQube server 7.9.1
INFO: Default locale: "en_US", source code encoding: "US-ASCII" (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=186ms
INFO: Server id: A7EE8CF2-AXI9JaBwRGaHU4KxYo1w
INFO: User cache: /var/jenkins_home/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=63ms
INFO: Load/download plugins (done) | time=136ms
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=9ms
INFO: Project key: com.authentication.microservice:authentication-service
INFO: Base dir: /var/jenkins_home/workspace/AuthenticationService
INFO: Working dir: /var/jenkins_home/workspace/AuthenticationService/.scannerwork
INFO: Load project settings for component key: 'com.authentication.microservice:authentication-service'
INFO: Load project settings for component key: 'com.authentication.microservice:authentication-service' (done) | time=83ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=185ms
INFO: Detected Jenkins
INFO: Load active rules
INFO: Load active rules (done) | time=2071ms
INFO: Indexing files...
INFO: Project configuration:
INFO: 16 files indexed
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for java: Sonar way
INFO: ------------- Run sensors on module AuthenticationService
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=63ms
INFO: Sensor JavaSquidSensor [java]
INFO: Configured Java source version (sonar.java.source): none
INFO: JavaClasspath initialization
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 9.490s
INFO: Final Memory: 14M/34M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
org.sonar.java.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property
at org.sonar.java.JavaClasspath.init(JavaClasspath.java:64)
at org.sonar.java.AbstractJavaClasspath.getElements(AbstractJavaClasspath.java:280)
at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:209)
at org.sonar.java.JavaSquid.<init>(JavaSquid.java:84)
at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:87)
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.execute(Batch.java:67)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
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:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
ERROR:
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
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
Made it work by adding
sonar.java.binaries=**/target/classes
to the analysis properties of the sonar scanner. I also changed the sonar.sources property to
sonar.sources=microservices/authentication-service/src/main/java/
So the whole analysis properties in my configuration look now like this:
sonar.projectKey=com.authentication.microservice:authentication-service
sonar.projectName=AuthenticationService
sonar.projectVersion=1.0
sonar.sources=microservices/authentication-service/src/main/java/
sonar.java.binaries=**/target/classes
disable lightweight checkout in jenkins job configuration. add checkout scm in scripted pipeline stage. this worked for me

Sonar Maven HTTP error: 401

Need some help. Currently writing custom rules for my company. But during testing I encountered a problem. When I start local sonar and try to run project on it to test new rules, I get BUILD FAILURE. This is what I see when running project:
C:\Users\tgriusys\eclipse-workspace\simpleProject>mvn sonar:sonar
14:37:12:900 [INFO] Scanning for projects...
14:37:13:353 [INFO]
14:37:13:353 [INFO] ------------------------------------------------------------------------
14:37:13:353 [INFO] Building simpleProject 0.0.1-SNAPSHOT
14:37:13:353 [INFO] ------------------------------------------------------------------------
14:37:13:451 [INFO]
14:37:13:451 [INFO] --- sonar-maven-plugin:3.4.0.905:sonar (default-cli) # simpleProject ---
14:37:13:815 [INFO] User cache: C:\Users\tgriusys\.sonar\cache
14:37:13:897 [INFO] SonarQube version: 6.7.1
14:37:13:916 [INFO] Default locale: "en_US", source code encoding: "windows- 1257" (analysis is platform dependent)
14:37:14:178 [INFO] Publish mode
14:37:14:317 [INFO] Load global settings
14:37:14:388 [INFO] Load global settings (done) | time=72ms
14:37:14:396 [INFO] Server id: AWDU5v5flIPWulLSdQv7
14:37:14:405 [INFO] User cache: C:\Users\tgriusys\.sonar\cache
14:37:14:682 [INFO] Load plugins index
14:37:14:736 [INFO] Load plugins index (done) | time=54ms
14:37:15:313 [INFO] Process project properties
14:37:15:383 [INFO] Load project repositories
14:37:15:917 [INFO] Load project repositories (done) | time=534ms
14:37:16:027 [INFO] Load quality profiles
14:37:16:267 [INFO] Load quality profiles (done) | time=240ms
14:37:16:287 [INFO] Load active rules
14:37:16:498 [INFO] Load active rules (done) | time=211ms
14:37:16:502 [INFO] Load metrics repository
14:37:16:526 [INFO] Load metrics repository (done) | time=25ms
14:37:16:539 [INFO] Project key: simpleProject:simpleProject
14:37:16:540 [INFO] ------------- Scan simpleProject
14:37:16:641 [INFO] Base dir: C:\Users\tgriusys\eclipse-workspace\simpleProject
14:37:16:641 [INFO] Working dir: C:\Users\tgriusys\eclipse-workspace\simpleProject\target\sonar
14:37:16:644 [INFO] Source paths: pom.xml, src/main/java
14:37:16:644 [INFO] Test paths: src/test/java
14:37:16:645 [INFO] Source encoding: windows-1257, default locale: en_US
14:37:16:679 [INFO] Load server rules
14:37:16:798 [INFO] Load server rules (done) | time=119ms
14:37:16:905 [INFO] Index files
14:37:16:922 [INFO] 7 files indexed
14:37:16:923 [INFO] Quality profile for java: Exigen Coverage
14:37:16:924 [INFO] Quality profile for xml: Sonar way
14:37:17:054 [INFO] Sensor JavaSquidSensor [java]
14:37:17:189 [INFO] Configured Java source version (sonar.java.source): 5
14:37:17:222 [INFO] JavaClasspath initialization
14:37:17:238 [INFO] JavaClasspath initialization (done) | time=16ms
14:37:17:239 [INFO] JavaTestClasspath initialization
14:37:17:242 [INFO] JavaTestClasspath initialization (done) | time=3ms
14:37:17:508 [INFO] Java Main Files AST scan
14:37:17:509 [INFO] 6 source files to be analyzed
14:37:17:948 [INFO] Java Main Files AST scan (done) | time=439ms
14:37:17:948 [INFO] 6/6 source files have been analyzed
14:37:17:948 [INFO] Java Test Files AST scan
14:37:17:949 [INFO] 0 source files to be analyzed
14:37:17:950 [INFO] Java Test Files AST scan (done) | time=2ms
14:37:17:950 [INFO] 0/0 source files have been analyzed
14:37:17:951 [INFO] Sensor JavaSquidSensor [java] (done) | time=897ms
14:37:17:952 [INFO] Sensor FindBugs Sensor [findbugs]
14:37:19:188 [INFO] Loading findbugs plugin: C:\Users\tgriusys\eclipse-workspace\simpleProject\target\sonar\findbugs\findsecbugs-plugin.jar
14:37:19:207 [INFO] Findbugs output report: C:\Users\tgriusys\eclipse-workspace\simpleProject\target\sonar\findbugs-result.xml
14:37:20:931 [INFO] Sensor FindBugs Sensor [findbugs] (done) | time=2979ms
14:37:20:932 [INFO] Sensor SurefireSensor [java]
14:37:20:933 [INFO] parsing [C:\Users\tgriusys\eclipse-workspace\simpleProject\target\surefire-reports]
14:37:20:935 [INFO] Sensor SurefireSensor [java] (done) | time=3ms
14:37:20:935 [INFO] Sensor JaCoCoSensor [java]
14:37:20:938 [INFO] Sensor JaCoCoSensor [java] (done) | time=3ms
14:37:20:938 [INFO] Sensor SonarJavaXmlFileSensor [java]
14:37:20:950 [INFO] 1 source files to be analyzed
14:37:21:577 [INFO] Sensor SonarJavaXmlFileSensor [java] (done) | time=639ms
14:37:21:578 [INFO] 1/1 source files have been analyzed
14:37:21:578 [INFO] Sensor XML Sensor [xml]
14:37:21:719 [INFO] Sensor XML Sensor [xml] (done) | time=141ms
14:37:21:719 [INFO] Sensor Zero Coverage Sensor
14:37:21:737 [INFO] Sensor Zero Coverage Sensor (done) | time=18ms
14:37:21:738 [INFO] Sensor CPD Block Indexer
14:37:21:757 [INFO] Sensor CPD Block Indexer (done) | time=19ms
14:37:21:758 [INFO] SCM Publisher is disabled
14:37:21:759 [INFO] 6 files had no CPD blocks
14:37:21:759 [INFO] Calculating CPD for 0 files
14:37:21:760 [INFO] CPD calculation finished
14:37:21:889 [INFO] Analysis report generated in 112ms, dir size=19 KB
14:37:21:931 [INFO] Analysis reports compressed in 41ms, zip size=15 KB
14:37:21:956 [INFO] Analysis report uploaded in 24ms
14:37:21:957 [INFO] ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/simpleProject:simpleProject
14:37:21:958 [INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
14:37:21:959 [INFO] More about the report processing at http://localhost:9000/api/ce/task?id=AWOCfVUd_KYAMsLyvlL2
14:37:21:962 [INFO] Executing post-job org.sonar.report.pdf.batch.PDFPostJob
14:37:21:963 [INFO] Executing decorator: PDF Report
14:37:21:972 [INFO] Team workbook report type selected
14:37:22:058 [INFO] Retrieving project info for simpleProject:simpleProject
14:37:22:234 [INFO] ------------------------------------------------------------------------
14:37:22:234 [INFO] BUILD FAILURE
14:37:22:235 [INFO] ------------------------------------------------------------------------
14:37:22:236 [INFO] Total time: 9.616 s
14:37:22:237 [INFO] Finished at: 2018-05-21T14:37:22+03:00
14:37:22:369 [INFO] Final Memory: 27M/981M
14:37:22:369 [INFO] ------------------------------------------------------------------------
14:37:22:373 [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar (default-cli) on project simpleProject: HTTP error: 401, msg: , query: org.apache.commons.httpclient.methods.GetMethod#5d957cf0 -> [Help 1]
14:37:22:374 [ERROR]
14:37:22:375 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
14:37:22:375 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
14:37:22:376 [ERROR]
14:37:22:376 [ERROR] For more information about the errors and possible solutions, please read the following articles:
14:37:22:377 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
After this I can check analysis and check if rules are working properly but I wonder why build fails and what can I do to solve it?
In my situation,it`s the pdf report plugin that caused the BUILD FAILURE error.
After the plugin is removed in the sonarqube web and server dir ,then the analysis goes well.
Here is the part of error message:
An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar: java.lang.NoSuchMethodError: org.sonar.api.batch.postjob.PostJobContext.settings()Lorg/sonar/api/config/Settings;

Analyse TypeScript SonarQube in Maven project

I'll try to use the SonarQube SonarTS plugin to analyse TypeScript files in a project of mine.
It contains a submodule that contains some images, some xmls, and a couple of .ts-files. I have installed SonarTS ( https://docs.sonarqube.org/display/PLUG/SonarTS ) in SonarQube. The project uses typescript 2.4.2 as a devDependency and is build with Node 6.13.1.
When I call mvn sonar:sonar -Dsonar.branch=<BRANCHNAME> (I know sonar.branch is deprecated, I'll fix soon :)), eventually the sum-module is scanned and this is the log:
[INFO] ------------- Scan MyProject
[INFO] Base dir: /home/jenkins/workspace/my-project/my-project-config-model
[INFO] Working dir: /home/jenkins/workspace/my-project/my-project-config-model/target/sonar
[INFO] Source paths: pom.xml
[INFO] Source encoding: UTF-8, default locale: en_US
[INFO] Index files
[INFO] 1 file indexed
[INFO] Quality profile for xml: Sonar way
[INFO] Sensor Embedded CSS Analyzer Sensor [css]
[INFO] 0 source files to be analyzed
[INFO] Sensor Embedded CSS Analyzer Sensor [css] (done) | time=1ms
[INFO] Sensor SonarJavaXmlFileSensor [java]
[INFO] 0/0 source files have been analyzed
[INFO] 1 source files to be analyzed
[INFO] Sensor SonarJavaXmlFileSensor [java] (done) | time=31ms
[INFO] 1/1 source files have been analyzed
[INFO] Sensor XML Sensor [xml]
[INFO] Sensor XML Sensor [xml] (done) | time=8ms
[INFO] SCM provider for this project is: git
[INFO] 1 files to be analyzed
[INFO] 0/1 files analyzed
And the only file that is scanned is the pom.xml
Could it have something to do with the structure of the sub-module? The xmls and ts files are not at src/main/{ts|resources}, but src/models and src/scripts.
Thanks in advance!
I guess you need to change the sonar.sources parameter to include your source folders (something like sonar.sources=src/main/java,src/models,src/scripts should work).
You can find more about analysis parameters here, and more about the way to configure the maven scanner here.

SonarQube 6.3 fails on trying to scan a binary file

after successfully upgrading from sonarqube 6.2 to 6.3 the analyzation process of one project fails. The error message is Unable to read the source file : '.../ajax.gif' with the charset : 'UTF-8'. Input length = 1. When I run file .../ajax.gif then I get GIF image data, version 89a, 220 x 19 as expected. Before upgrading to 6.3 everything was working fine.
Here is the complete output:
CLI command: mvn clean sonar:sonar
Outcome:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building pp-scratch 1.1.17-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.2:sonar (default-cli) # pp-scratch ---
[INFO] User cache: /home/thomas/.sonar/cache
[INFO] Load global settings
[INFO] Load global settings (done) | time=235ms
[INFO] User cache: /home/thomas/.sonar/cache
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=9ms
[INFO] Plugin [l10nde] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2.
[INFO] SonarQube version: 6.3.0
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
[INFO] Process project properties
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=124ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=85ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=539ms
[INFO] Load metrics repository
[INFO] Load metrics repository (done) | time=103ms
[INFO] Publish mode
[INFO] Project key: de.tln:pp-scratch
[INFO] ------------- Scan pp-scratch
[INFO] Excluded sources for coverage:
[INFO] **/*DTO.java
[INFO] Load server rules
[INFO] Load server rules (done) | time=97ms
[INFO] Initializer GenericCoverageSensor
[INFO] Initializer GenericCoverageSensor (done) | time=0ms
[INFO] Base dir: /home/thomas/workspace/aexit/pp-scratch
[INFO] Working dir: /home/thomas/workspace/aexit/pp-scratch/target/sonar
[INFO] Source paths: src/main/webapp, pom.xml, src/main/java
[INFO] Test paths: src/test/java
[INFO] Source encoding: UTF-8, default locale: en_US
[INFO] Index files
[INFO] Excluded sources:
[INFO] **/*.min.css
[INFO] **/*.min.js
[INFO] src/main/webapp/resources/bootstrap/**
[INFO] **/entity/*.java
[INFO] 210 files indexed
[INFO] 7 files ignored because of inclusion/exclusion patterns
[INFO] Quality profile for css: Sonar way
[INFO] Quality profile for java: TLN
[INFO] Quality profile for js: Sonar way
[INFO] Quality profile for web: Sonar way
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.309 s
[INFO] Finished at: 2017-03-24T08:18:22+01:00
[INFO] Final Memory: 61M/514M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project pp-scratch: Unable to read the source file : '/home/thomas/workspace/aexit/pp-scratch/src/main/webapp/resources/app/ajaxloadingbar.gif' with the charset : 'UTF-8'. Input length = 1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1
You are facing the following bug: SONAR-8995
It will be fixed in SonarQube 6.3.1.

SonarQube doesn't generate "duplications" information

I've managed to install SonarQube 5.1 using the official docker image from SonarSource.
I am actually running sonar using the default H2 DB and I have got almost eveything woking for my demo Java project: Coverage, unit tests and issues.
However, the duplications are 0%. I have created a test classes with the following code:
public class Test {
public Test() {
for(int i = 0; i < 10; i++)
{
System.out.println("Test");
System.out.println("Test");
System.out.println("Test");
}
for(int i = 0; i < 10; i++)
{
System.out.println("Test");
System.out.println("Test");
System.out.println("Test");
}
}
How can be the duplications 0%? I think something is not working in my set...
In addition, Sonar has detected some major issues in my class, but nothing related with the duplications:
Hide this public constructor
Replace this usage of System.out or System.err by a logger
In order to generate the sonar report, I am executing sonar:sonar using maven. That's the output:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building demoservice 0.1.0.-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:2.6:sonar (default-cli) # demoservice ---
[INFO] SonarQube version: 5.1
INFO: Default locale: "en_GB", source code encoding: "UTF-8"
INFO: Work directory: W:\DemoService\target\sonar
INFO: SonarQube Server 5.1
[INFO] [15:52:47.080] Load global repositories
[INFO] [15:52:47.290] Load global repositories (done) | time=212ms
[INFO] [15:52:47.293] Server id: 20150917085707
[INFO] [15:52:47.295] User cache: C:\Users\jose.valencia\.sonar\cache
[INFO] [15:52:47.303] Install plugins
[INFO] [15:52:47.402] Install JDBC driver
[INFO] [15:52:47.412] Create JDBC datasource for jdbc:h2:tcp://localhost:9092/sonar
[INFO] [15:52:48.524] Initializing Hibernate
[INFO] [15:52:50.183] Load project repositories
[INFO] [15:52:51.840] Load project repositories (done) | time=1657ms
[INFO] [15:52:51.841] Load project settings
[INFO] [15:52:52.252] Load technical debt model
[INFO] [15:52:52.285] Apply project exclusions
[INFO] [15:52:53.136] ------------- Scan demoservice
[INFO] [15:52:53.139] Load module settings
[INFO] [15:52:53.238] Language is forced to java
[INFO] [15:52:53.244] Load rules
[INFO] [15:52:53.437] Base dir: W:\DemoService
[INFO] [15:52:53.437] Working dir: W:\DemoService\target\sonar
[INFO] [15:52:53.438] Source paths: pom.xml, src/main/java
[INFO] [15:52:53.438] Test paths: src/test/java
[INFO] [15:52:53.439] Binary dirs: target/classes
[INFO] [15:52:53.439] Source encoding: UTF-8, default locale: en_GB
[INFO] [15:52:53.439] Index files
[INFO] [15:52:53.456] 9 files indexed
[INFO] [15:52:53.642] Quality profile for java: Sonar way
[INFO] [15:52:53.672] Sensor JavaSquidSensor
[INFO] [15:52:55.794] Java Main Files AST scan...
[INFO] [15:52:55.796] 6 source files to be analyzed
[INFO] [15:52:57.434] Java Main Files AST scan done: 1640 ms
[INFO] [15:52:57.435] 6/6 source files have been analyzed
[INFO] [15:52:57.437] Java bytecode scan...
[INFO] [15:52:57.551] Java bytecode scan done: 114 ms
[INFO] [15:52:57.551] Java Test Files AST scan...
[INFO] [15:52:57.552] 3 source files to be analyzed
[INFO] [15:52:58.106] Java Test Files AST scan done: 555 ms
[INFO] [15:52:58.107] 3/3 source files have been analyzed
[INFO] [15:52:58.111] Package design analysis...
[INFO] [15:52:58.164] Package design analysis done: 53 ms
[INFO] [15:52:58.193] Sensor JavaSquidSensor (done) | time=4521ms
[INFO] [15:52:58.193] Sensor Lines Sensor
[INFO] [15:52:58.196] Sensor Lines Sensor (done) | time=3ms
[INFO] [15:52:58.196] Sensor QProfileSensor
[INFO] [15:52:58.201] Sensor QProfileSensor (done) | time=5ms
[INFO] [15:52:58.201] Sensor InitialOpenIssuesSensor
[INFO] [15:52:58.270] Sensor InitialOpenIssuesSensor (done) | time=69ms
[INFO] [15:52:58.270] Sensor ProjectLinksSensor
[INFO] [15:52:58.286] Sensor ProjectLinksSensor (done) | time=16ms
[INFO] [15:52:58.286] Sensor VersionEventsSensor
[INFO] [15:52:58.309] Sensor VersionEventsSensor (done) | time=23ms
[INFO] [15:52:58.309] Sensor Maven dependencies
[INFO] [15:53:01.186] Sensor Maven dependencies (done) | time=2877ms
[INFO] [15:53:01.186] Sensor CoberturaSensor
[INFO] [15:53:01.186] parsing W:\DemoService\target\site\cobertura\coverage.xml
[INFO] [15:53:01.283] Sensor CoberturaSensor (done) | time=97ms
[INFO] [15:53:01.283] Sensor SurefireSensor
[INFO] [15:53:01.284] parsing W:\DemoService\target\surefire-reports
[INFO] [15:53:01.302] Sensor SurefireSensor (done) | time=19ms
[INFO] [15:53:01.302] Sensor SCM Sensor
[INFO] [15:53:01.309] SCM provider for this project is: git
[INFO] [15:53:01.313] 1 files to be analyzed
[INFO] [15:53:01.548] 1/1 files analyzed
[INFO] [15:53:01.549] Sensor SCM Sensor (done) | time=247ms
[INFO] [15:53:01.549] Sensor CPD Sensor
[INFO] [15:53:01.549] JavaCpdEngine is used for java
[INFO] [15:53:01.549] Cross-project analysis disabled
[INFO] [15:53:01.595] Sensor CPD Sensor (done) | time=46ms
[INFO] [15:53:01.596] No quality gate is configured.
[INFO] [15:53:01.642] Compare to previous analysis (2015-09-17)
[INFO] [15:53:01.651] Compare over 30 days (2015-08-18, analysis of Wed Sep 16 17:23:06 BST 2015)
[INFO] [15:53:01.944] Execute decorators...
[INFO] [15:53:02.987] Store results in database
[INFO] [15:53:04.851] Analysis reports generated in 75ms, dir size=8 KB
[INFO] [15:53:04.879] Analysis reports compressed in 28ms, zip size=8 KB
[INFO] [15:53:04.914] Analysis reports sent to server in 35ms
[INFO] [15:53:04.915] ANALYSIS SUCCESSFUL, you can browse http://10.1.2.77:9001/dashboard/index/pbs.demoservice:demoservice
[INFO] [15:53:04.915] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.371s
[INFO] Finished at: Thu Sep 17 15:53:05 BST 2015
[INFO] Final Memory: 37M/896M
[INFO] ------------------------------------------------------------------------
I am not sure if I have missed something or something is not configured properly. Any ideas?
Thanks!
I have found the problem. For Java projects, the duplication detection mechanism behaves slightly differently as a piece of code is considered as duplicated as soon as there is the same sequence of 10 successive statements whatever is the number of tokens and lines. Therefore, I have managed to see the duplications after adding more duplicated loops in my Test class.

Resources