How to avoid "GC overhead limit exceeded"? - jenkins

Our Sonar Build Environment details as follows:
* SonarQube Server Version - 5.6.7 (64-Bit).
* Sonar Client Build Operating System – Ubuntu-14.04 (LTS - 64-Bit).
* Sonar Build machine total RAM: 16-GB.
* Sonar-Scanner- Version - 3.0.3.778.
* sonar-cxx-plugin-0.9.7.jar
* Source Code Language: C++
* Client Machine Java Version: 1.8
* Source Code Size: 62-GB.
Problem:
Through Jenkins sonar-scanner finished successfully (Log as follows).
Jenkins Sonar-Scanner Build Log:
12:24:14 INFO: CPD calculation finished
12:26:35 INFO: Analysis report generated in 136049ms, dir size=1 GB
12:49:25 INFO: Analysis reports compressed in 1369236ms, zip size=385 MB
12:49:43 INFO: Analysis report uploaded in 18811ms
12:49:43 INFO: ANALYSIS SUCCESSFUL, you can browse http://sonarqube-server/dashboard/index/scm.project.4.0
12:49:43 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
12:49:43 INFO: More about the report processing at http://sonarqube-server/api/ce/task?id=AV-af9So2HbsBuSrsvrw
12:50:22 INFO: ------------------------------------------------------------------------
12:50:22 INFO: EXECUTION SUCCESS
Whereas Sonarqube project dashboard shows "No analysis has been performed since creation. The only available section is the configuration." And also under SonarQube Web--> Project--> Administration-->Background Tasks-->Logs shows below errors.
Error:
2017.11.07 13:04:23 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Failed to execute task AV-VUEIr2HbsBuSrsvnY
java.lang.OutOfMemoryError: GC overhead limit exceeded
I have tried the following, still same problem persists.
Tried with SONAR_RUNNER_OPTS option with -Xmx10240m -XX:MaxPermSize=1024m -XX:ReservedCodeCacheSize=128m
Then in sonar-project.properties file I have added sonar.ce.javaOpts=-Xmx1280m & sonar.web.javaOpts=-Xmx1280m
Or still I need to increase the build machine RAM (or) 16-GB is sufficient for 62-GB Code?

You need to upgrade the memory allocated for Compute Engine on the server side not on the scanner side (for this particular issue).
So on your SonarQube server, update the following parameter :
sonar.ce.javaOpts=-Xmx2G -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true
It will allow Compute Engine which will integrate your report to consume 2Gb of memory (by default it's 512Mb).

Related

integrating sonarqube with jenkins insufficient privileges error

I followed this video https://www.youtube.com/watch?v=jh7utASgKj4 to integrate sonarqube with jenkins. However, I get the insufficient privileges error when scanning the code by sonarqube server. The version of sonarqube server is 6.7. how can I solve this problem?
Here is the analysis properties in the jenkins project
# Required metadata
sonar.projectKey = test-sonar
# Path to source directory
sonar.sources = /var/jenkins_home/workspace/$JOB_NAME/test-sonar/src
# bind sonar.java.binaries property
sonar.java.binaries=/var/jenkins_home/workspace/$JOB_NAME/test-sonar/target/classes
Here is the output of console.
INFO: SCM provider for this project is: git
INFO: 16 files to be analyzed
INFO: 16/16 files analyzed
INFO: 5 files had no CPD blocks
INFO: Calculating CPD for 8 files
INFO: CPD calculation finished
INFO: Analysis report generated in 132ms, dir size=124 KB
INFO: Analysis reports compressed in 48ms, zip size=61 KB
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 48.028s
INFO: Final Memory: 15M/304M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Insufficient privileges
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?
ERROR: SonarQube scanner exited with non-zero code: 1
If you are running the Sonar Analysis via Execute shell plugin for Jenkins, you need to supply the Username Password of a User which has the Execute Analysis rights on the SonarQube server you are trying to access.
To supply the username in the shell, you can use
-Dsonar.login=yourLoginName -Dsonar.password=*****
To set the Execute Analysis permission you can ask your DevOps team to give you access or if you are looking into that,
Goto Administration > Security > User/Groups.
Please make sure that you configure the Sonarqube UserID and Password having privileges to access sonar server (execute analysis permissions) in the Sonar plugin for Jenkins. This error might appear for 5.3 and higher versions when the anonymous access to sonar is disabled.

SonarQube plug-in not scanning C# files during TFS Build

I am running SonarQube server v6.4 with v6.1 of the C# plugin. We have v3.0.0 of the SonarQube TFS extension installed in our TFS 2015 (Update 3) instance.
I am having issues with SonarQube scanning .cs files. There are a few warnings in the output of a few build steps that I'm not entirely sure what to make of. I haven't been able to find much on the messages.
Visual Studio Build step output:
OverrideCodeAnalysisProperties:
Skipping FxCop analysis: the SonarQube ruleset does not exist. Ruleset: C:\BuildAgents\Agent-01\_work\111\.sonarqube\conf\\SonarQubeFxCop-cs.ruleset
SonarQube Scanner for MSBuild - End Analysis (new) step output:
I'm seeing this at the beginning of the output for the step...
SonarQube Scanner for MSBuild 3.0
Default properties file was found at C:\BuildAgents\Agent-01\tasks\SonarQubeScannerMsBuildBegin\3.0.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Loading analysis properties from C:\BuildAgents\Agent-01\tasks\SonarQubeScannerMsBuildBegin\3.0.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Post-processing started.
17:58:54.965 17:58:54.965 WARNING: Failed to find the code coverage command line tool. Possible cause: Visual Studio is not installed, or the installed version does not support code coverage.
WARNING: File is not under the project directory and cannot currently be analysed by SonarQube. File: C:\Users\TFS2015Build\AppData\Local\Temp\.NETFramework,Version=v4.5.2.SqlClrAttributes.cs, project: C:\BuildAgents\Agent-01\_work\111\s\FunProject.Db\FunProject.Db.sqlproj
SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx1024m
Calling the SonarQube Scanner...
INFO: Scanner configuration file: C:\BuildAgents\Agent-01\tasks\SonarQubeScannerMsBuildBegin\3.0.0\SonarQubeScannerMsBuild\sonar-scanner-3.0.3.778\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\sonar-project.properties
INFO: SonarQube Scanner 3.0.3.778
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
INFO: Windows Server 2012 R2 6.3 amd64
INFO: SONAR_SCANNER_OPTS=-Xmx1024m
INFO: User cache: C:\Users\TFS2015Build\.sonar\cache
INFO: Load global settings
INFO: Load global settings (done) | time=125ms
INFO: User cache: C:\Users\TFS2015Build\.sonar\cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=0ms
INFO: Download sonar-csharp-plugin-6.1.0.2359.jar
INFO: Download sonar-python-plugin-1.8.0.1496.jar
INFO: Download sonar-java-plugin-4.11.0.10660.jar
INFO: Download sonar-flex-plugin-2.3.jar
INFO: Download sonar-scm-git-plugin-1.2.jar
INFO: Download sonar-xml-plugin-1.4.3.1027.jar
INFO: Download sonar-php-plugin-2.10.0.2087.jar
INFO: Download sonar-scm-svn-plugin-1.4.0.522.jar
INFO: Download sonar-javascript-plugin-3.1.1.5128.jar
INFO: SonarQube server 6.4.0
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=141ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=47ms
INFO: Load active rules
INFO: Load active rules (done) | time=281ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=78ms
INFO: Publish mode
...then I'm seeing a set of output like this for each project in my solution:
INFO: ------------- Scan FunProject.Shared
INFO: Load server rules
INFO: Load server rules (done) | time=156ms
INFO: Initializer GenericCoverageSensor
INFO: Initializer GenericCoverageSensor (done) | time=0ms
INFO: Base dir: C:\BuildAgents\Agent-01\_work\111\s\FunProject.Shared
INFO: Working dir: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\.sonar\mod13
INFO: Source paths: FunProjectFolder1/FunProjectClassFile1.cs, FunProjectFolder2/FunProjectClassFile2.cs, ... Properties/AssemblyInfo.cs, packages.config
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: Analyzer working directory does not exist
INFO: 12 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# [csharp]
INFO: Importing analysis results from C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\encoding.pb
INFO: Importing Roslyn report
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\metrics.pb
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\token-type.pb
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\symrefs.pb
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\token-cpd.pb
INFO: Sensor C# [csharp] (done) | time=78ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=0ms
Is there something obvious that I'm missing?
Edit:
I am using Visual Studio Professional, so the warning about code coverage is caused by the fact that I do not have Visual Studio Enterprise installed on the build server.
Suggest you first try to analyze solution in the command line locally to see if it works.
Run your analysis by executing the following commands from the root directory of the project:
SonarQube.Scanner.MSBuild.exe begin /k:"org.sonarqube:sonarqube-scanner-msbuild" /n:"Project Name" /v:"1.0"
MSBuild.exe /t:Rebuild
SonarQube.Scanner.MSBuild.exe end
This will narrow down it's your environment issue or just related to your build definition settings.
According to the error message:
WARNING: Failed to find the code coverage command line tool. Possible
cause: Visual Studio is not installed, or the installed version does
not support code coverage.
Double check your VS edition on your build agent. Note: you need Visual Studio Enterprise edition for code coverage. Have a look at this page and expand the 'testing tools' section. Code coverage is only listed for the Enterprise edition.
Besides, you could also enable verbose Debug Mode with system.debug=true to get a more detail build log for troubleshooting.
I downgraded the C# plugin from 6.1 (build 2359) to 5.11 (build 1721), and the problem went away. There must be some issue with that release that was causing the issue.

Error during SonarQube Scanner execution from Jenkins plugin

I get the following error when I try to execute SonarQube Scanner as a part of Jenkins build:
ERROR: SonarQube server [http://<hostname>:9000] can not be reached
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.242s
INFO: Final Memory: 5M/483M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:84)
at
... 8 more
Caused by: java.lang.IllegalStateException: Status returned by
url [http://<hostname>:9000/batch/index] is not valid: [404]
at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:115)
at org.sonarsource.scanner.api.internal.Jars.getBootstrapIndex(Jars.java:96)
... 12 more
ERROR:
I can access the following URL from my Jenkins host: http://:9000/sonar/ . When I try to execute this:
wget http://<hostname>:9000/batch/index
I get the same 404 http error in response. I have no idea from where this URL postfix /batch/index comes from. Web search did not give any clues for this.
My Sonar version is 6.0. My Jenkins Sonar Scanner plugin version is 2.6.1.
Used JVM:
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
What is your the setting for sonar's web context (sonar.web.context) on your sonar server? It would be inside of sonar.properties. By default both the Jenkins plugin and the sonar server configuration set it to root:
'http://<hostname>:9000/'
The first thing I would do is to make sure those are matching in the sonar configuration and the jenkins plugin configuration.
I've seen tutorials that tell you to use /sonar or something similar. In that case, the jenkins plugin would need to be set to /sonar as well, like:
'http://<hostname>:9000/sonar'

How to filter files in sonar SCM?

I have installed a CI environment for my PHP project.
I use jenkins + sonar + Gitlab.
All things seem great until build a jenkins job.
The error info is
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 2:03.218s
Final Memory: 345M/456M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: Unable to blame file src/apps/conf.php. No blame info at line 1. Is file commited?
10:21:17.165 INFO - Author: PersonIdent[Not Committed Yet, , Wed Feb 4 10:21:17 2015 +0800]
ERROR:
I find sonar SCM-Activity-Plugin report this bug.
The conf.php file is my config file and can not push to Gitlab.
So, Is there a way to ask SCM-Activity-Plugin filter these config files?
thanks a lot!
Excluding the file from sonar analysis might help.
Login to sonar using admin or user that have got administrative rights in the project.
Open the project and select “Settings” from “Project Configuration”.
There click on “Exclusions” link and take “File” tab.
Under “Source File Exclusions” give your file as src/apps/conf.php

Sonar Runner does not use properties of sonar-project.properties

I am using SonarQube Runner 2.4 at jenkins since today but the analysis fail with the message:
SonarQube Runner 2.4
Java 1.7.0_51 Oracle Corporation (64-bit)
INFO: Runner configuration file: /.jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar_Runner_2.4/conf/sonar-runner.properties
INFO: Project configuration file: NONE
INFO: Default locale: "en_US", source code encoding: "ISO-8859-1" (analysis is platform dependent)
INFO: Work directory: /.jenkins/workspace/Sonar/.sonar
INFO: SonarQube Server 4.3.2
23:21:42.176 INFO - Load batch settings
23:21:42.160 INFO - User cache: /.sonar/cache
23:21:42.270 INFO - Install plugins
23:21:43.322 INFO - Install JDBC driver
23:21:43.329 INFO - Create JDBC datasource for jdbc:mysql://xxx
23:21:45.505 INFO - Initializing Hibernate
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 5.214s
Final Memory: 21M/429M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must define the following mandatory properties for ‚com.mypackage:MyProject: sonar.sources
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
[BFA] Scanning build for known causes...
[BFA] Done. 0s
Notifying upstream projects of job completion
Finished: FAILURE
If I add the property "MyProject.sonar.sources=src" In the project properties in Jenkins (I use "Invoke Standalone Sonar Analysis"). I will receive the error message
ERROR: Caused by: Findbugs needs sources to be compiled. Please build project before executing sonar and check the location of compiled classes.
This means the sonar-project.properties (/.jenkins/workspace/Deploy/MyProject/sonar-project.properties) is not read or used because there are all values defined:
sonar.language=java
sonar.projectName=MyProject
sonar.projectVersion=0.1
sonar.binaries=bin
sonar.projectDescription=
sonar.projectKey=MyProjectKey
sonar.sources=src
When sonar is executed I can see the correct path to MyProject where :
-DMyProject.sonar.projectBaseDir=/.jenkins/workspace/Deploy/MyProject
Or does the name of sonar-project.properties changed?
Please build the project in the release mode. After the build happens you will get the dll's produced somewhere. you have to point to that location.

Resources