Metric 'it_lines_cover' should not be computed by a Sensor - sonarqube

I've got an error during phpunit coverage report parsing with SonarQube Scanner 2.8 with following message :
Metric 'it_lines_to_cover' should not be computed by a Sensor
Thanks in advance,
Versions :
10:42:57.262 INFO: SonarQube Scanner 2.8
10:42:57.262 INFO: Java 1.8.0_111 Oracle Corporation (64-bit)
10:42:57.262 INFO: Linux 3.13.0-103-generic amd64
10:43:08.803 DEBUG: * PHP 2.9.1.1705 (php)
Error log :
10:43:18.046 INFO: Sensor PHP sensor
10:43:18.420 INFO: 78 source files to be analyzed
10:43:21.533 INFO: 78/78 source files have been analyzed
10:43:21.543 INFO: PHPUnit xml test report not found: tests/build
/logs/junit_unit.xml
10:43:21.544 INFO: PHPUnit xml unit test coverage report not found:
tests/build/logs/clover-unit.xml
10:43:21.544 INFO: Analyzing PHPUnit integration test coverage report:
tests/build/logs/clover-integration.xml with PHPUnit IT Coverage Result Parser
10:43:21.544 DEBUG: Parsing file: /home/travis/build/armadito
/glpi/plugins/armadito/tests/build/logs/clover-integration.xml
10:43:23.079 DEBUG: Coverage metrics have not been set on 'index.php':
default values will be inserted.
------------------------------------------------------------------------
10:43:23.084 INFO: EXECUTION FAILURE
10:43:23.084 INFO:
------------------------------------------------------------------------
10:43:23.515 ERROR: Error during SonarQube Scanner execution
java.lang.UnsupportedOperationException: Metric 'it_lines_to_cover' should not be computed by a Sensor
at org.sonar.scanner.sensor.DefaultSensorStorage.saveMeasure(DefaultSensorStorage.java:240)
at org.sonar.scanner.sensor.DefaultSensorStorage.store(DefaultSensorStorage.java:213)
at org.sonar.api.batch.sensor.measure.internal.DefaultMeasure.doSave(DefaultMeasure.java:93)
at org.sonar.api.batch.sensor.internal.DefaultStorable.save(DefaultStorable.java:43)
at org.sonar.plugins.php.phpunit.PhpUnitCoverageResultParser.saveMeasureForMissingFiles(PhpUnitCoverageResultParser.java:129)
at org.sonar.plugins.php.phpunit.PhpUnitCoverageResultParser.parseFile(PhpUnitCoverageResultParser.java:102)
at org.sonar.plugins.php.phpunit.PhpUnitCoverageResultParser.parse(PhpUnitCoverageResultParser.java:84)
at org.sonar.plugins.php.phpunit.PhpUnitService.parseReport(PhpUnitService.java:74)
at org.sonar.plugins.php.phpunit.PhpUnitService.execute(PhpUnitService.java:60)
at org.sonar.plugins.php.PHPSensor.processCoverage(PHPSensor.java:142)
at org.sonar.plugins.php.PHPSensor.execute(PHPSensor.java:132)

This message will disappear once https://jira.sonarsource.com/browse/SONARPHP-658 is implemented. It is scheduled for next release of the PHP plugin.

Related

Sonarqube upload report 403

I have a Sonar analysis job in Jenkins which was working fine. Suddenly last week it started throwing error when uploading the report to Sonarqube server.
11:47:31 06:17:31.409 INFO: Analysis report generated in /var/jenkins_home/workspace/projectdirmasked/sample/.scannerwork/scanner-report
11:47:31 06:17:31.409 DEBUG: Upload report
11:47:31 06:17:31.481 DEBUG: POST 403 https://sonarqubehostnamemasked.com/api/ce/submit?projectKey=Sonar_Test&projectName=Sonar_Test | time=72ms
11:47:31 06:17:31.486 INFO: ------------------------------------------------------------------------
11:47:31 06:17:31.486 INFO: EXECUTION FAILURE
11:47:31 06:17:31.486 INFO: ------------------------------------------------------------------------
11:47:31 06:17:31.486 INFO: Total time: 9.877s
11:47:31 06:17:31.621 INFO: Final Memory: 39M/421M
11:47:31 06:17:31.621 INFO: ------------------------------------------------------------------------
11:47:31 06:17:31.621 ERROR: Error during SonarScanner execution
11:47:31 You're not authorized to run analysis. Please contact the project administrator.
The user belongs to the token has admin access. As well execute-analysis permission. And basically the user has assigned all the available permission in Sonarqube. So definitely it is not permission issue on the user.
All other projects using the same token in the same jenkins are able to scan successfully and upload the report.
Version: Enterprise Sonarqube 8.9.6
csharp plugin version: 8.22.0, xml plugin version: 2.2.0 (as I am scanning cs and xml files)
Any leads on this will be helpful!

is it possible to get sonarqube 8.6 exitcode from terminal based on analysis results?

Hi all I'm on linux and want to run sonarqube locally and based on the analysis result get exit code
So for example if 0 errors in code analysis then exit code 0
If it has 1 or more error in code analysis then exit code != 0
I run SQ server from docker-compose like this:
version: "3"
services:
sonarqube:
container_name: sonarqube
image: sonarqube:latest
ports:
- "9000:9000"
- "9092:9092"
and then with node I run sonarqube-scanner:
const sonarqubeScanner = require('sonarqube-scanner');
sonarqubeScanner({
serverUrl: 'http://localhost:9000',
options : {
'sonar.sources': '.',
'sonar.inclusions' : 'src/**',
}
}, () => {});
Finally I get success on console but no exit codes:
INFO: CPD Executor 4 files had no CPD blocks
INFO: CPD Executor Calculating CPD for 3 files
INFO: CPD Executor CPD calculation finished (done) | time=11ms
INFO: Analysis report generated in 74ms, dir size=97 KB
INFO: Analysis report compressed in 46ms, zip size=21 KB
INFO: Analysis report uploaded in 34ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=foobar
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://localhost:9000/api/ce/task?id=example
INFO: Analysis total time: 18.668 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 19.616s
INFO: Final Memory: 12M/50M
INFO: ------------------------------------------------------------------------
[11:10:42] Analysis finished.
It isn't practical for the sonar-scanner to return the scan results, because there are many details that a client might want to see. At the completion of the scan in the sonarqube server, a background task is run that produces the basic statistics based on the guidelines in the quality gate set in the project.
Typically, the SonarQube project has a "Webhook" value that specifies a url to post the background task results to, and that url is usually in Jenkins.
In a Jenkins scripted pipeline job, the "waitForQualityGate()" pipeline step is used to wait for that webhook call to be received.

sonar-scanner.bat fails with 401 on api/settings/values.protobuf when executed by jenkins pipeline

When I execute the pipeline below I get a 401 error on http://mysonarhost.my.domain:9000/api/settings/values.protobuf.
The same command executes without errors from a command prompt.
The api/settings/values.protobuf URL can be accessed using a browser.
I tried setting the token in various places but none seem to help .
Versions
sonarqube Version 6.3.1 (build 21392)
Jenkins ver. 2.75 on RHEL 7
Jenkins Node on windows 2012 R2
sonar-scanner 2.8
pipeline
https://i.imgur.com/S3Vk0fl.png
log
sonar-scanner -X -Dproject.settings=..\sonar_ccesmarttools.properties -Dsonar.logon=mytoken
06:32:33.829 INFO: Scanner configuration file: X:\workspaces\common\tools\hudson.plugins.sonar.SonarRunnerInstallation\SonarQubeScanner\bin\..\conf\sonar-scanner.properties
06:32:33.836 INFO: Project root configuration file: X:\cce\SmartLisaNightly\git\ccesmarttools\CceSmartTools\..\sonar_ccesmarttools.properties
06:32:33.873 INFO: SonarQube Scanner 3.0.3.778
06:32:33.874 INFO: Java 1.8.0_73 Oracle Corporation (64-bit)
06:32:33.874 INFO: Windows Server 2012 R2 6.3 amd64
06:32:33.874 INFO: SONAR_SCANNER_OPTS=-Xmx16g
06:32:34.041 DEBUG: keyStore is :
06:32:34.042 DEBUG: keyStore type is : jks
06:32:34.042 DEBUG: keyStore provider is :
06:32:34.042 DEBUG: init keystore
06:32:34.042 DEBUG: init keymanager of type SunX509
06:32:34.158 INFO: User cache: C:\Users\jenkinsuser\.sonar\cache
06:32:34.158 DEBUG: Extract sonar-scanner-api-batch in temp...
06:32:34.173 DEBUG: Get bootstrap index...
06:32:34.173 DEBUG: Download: http://mysonarhost.my.domain:9000/batch/index
06:32:34.232 DEBUG: Get bootstrap completed
06:32:34.233 DEBUG: Create isolated classloader...
06:32:34.243 DEBUG: Start temp cleaning...
06:32:34.255 DEBUG: Temp cleaning done
06:32:34.255 DEBUG: Execution getVersion
06:32:34.260 DEBUG: Execution start
06:32:34.557 DEBUG: Publish global mode
06:32:34.698 INFO: Load global settings
06:32:34.749 DEBUG: GET 401 http://mysonarhost.my.domain:9000/api/settings/values.protobuf | time=43ms
06:32:34.751 INFO: ------------------------------------------------------------------------
06:32:34.751 INFO: EXECUTION FAILURE
06:32:34.751 INFO: ------------------------------------------------------------------------
06:32:34.751 INFO: Total time: 0.961s
06:32:34.788 INFO: Final Memory: 17M/1963M
06:32:34.788 INFO: ------------------------------------------------------------------------
06:32:34.788 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.bootstrap.ScannerPluginInstaller
From the documentation, the property should be sonar.login, not sonar.logon.
I managed to solve it thanks to Gilles QUERRET answer and comments.
the token should be in the sonar.login property
added the withCredentials node
stored the token with id SONAR_TOKEN in http://myjenkinsserver:8090/credentials/store/system/domain/_/
changed single quotes in the bat command to double quotes to allow $SONAR_TOKEN to be evaluated
not part of the initial question, added -Dsonar.projectVersion=${env.BUILD_NUMBER} to show the Jenkins build number in SonarQube
Working stage definition
stage('SonarQube analysis') {
withSonarQubeEnv('SonarQube') {
withCredentials([string(credentialsId: 'SONAR_TOKEN', variable: 'SONAR_TOKEN')]) {
def scannerHome = tool 'SonarQubeScanner';
env.PATH = "${scannerHome}\\bin;${env.PATH}";
dir('X:\\cce\\SmartLisaNightly\\git\\smartlisa\\SmartLisaFrontend') {
bat "sonar-scanner -Dsonar.login=$SONAR_TOKEN -Dproject.settings=..\\sonar_SmartLisaFrontend.properties -Dsonar.projectVersion=${env.BUILD_NUMBER}"
}
}
}
}

SonarQube 6.0 with Sonar-Scanner-2.6.1 Cofinguration with MYSQL

I was using SonarQube 5.1.2 with Sonar-runner-dist 2.4 but I have to upgrade my SonarQube to 6.0 along with Sonar-Scanner-2.6.1
I was using MySQL for SonarQube 5.1.2 but When I upgraded to SonarQube 6.0 I am getting this error , Can someone help me how to override the error and what changes required with SonarQube 6.0
Not Sure why I am getting
WARN: Property 'sonar.jdbc.username' is not supported any more. It will be ignor
ed. There is no longer any DB connection to the SQ database.
Complete Error Log
WARN: sonar-runner.bat script is deprecated. Please use sonar-scanner.bat instea
d.
D:\Softwares\SonarQube_old\sonar-scanner-2.6.1\sonar-scanner-2.6.1
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
INFO: Scanner configuration file: D:\Softwares\SonarQube_old\sonar-scanner-2.6.1
\sonar-scanner-2.6.1\conf\sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 2.6.1
INFO: Java 1.8.0_111 Oracle Corporation (32-bit)
INFO: Windows 7 6.1 x86
INFO: User cache: C:\Users\391007\.sonar\cache
INFO: Load global repositories
INFO: Load global repositories (done) | time=124ms
WARN: Property 'sonar.jdbc.url' is not supported any more. It will be ignored. T
here is no longer any DB connection to the SQ database.
WARN: Property 'sonar.jdbc.username' is not supported any more. It will be ignor
ed. There is no longer any DB connection to the SQ database.
WARN: Property 'sonar.jdbc.password' is not supported any more. It will be ignor
ed. There is no longer any DB connection to the SQ database.
INFO: User cache: C:\Users\391007\.sonar\cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=9ms
INFO: SonarQube server 6.0
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is
platform dependent)
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 2.553s
INFO: Final Memory: 40M/96M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Unable to register extension com.sonar.governance.task.A.A from plugin 'g
overnance'
ERROR: Caused by: Lorg/sonar/batch/bootstrap/BatchWsClient;
ERROR: Caused by: org.sonar.batch.bootstrap.BatchWsClient
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Scanner with
the -e switch.
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging
I have referred below Answer but I am not getting solution to solve the problem
https://stackoverflow.com/a/35231407/3973543
"WARN: Property 'sonar.jdbc.url' is not supported any more " is not an error, just a warning, since 5.6 sonar.jdbc.url, sonar.jdbc.username and sonar.jdbc.password are not needed anymore in jenkins side. The sonarqube DataBase is only access from sonarqube instance, not from the clients as jenkins. So you should let them empty now. Just fill the sonarqube instance url for the WS connection.
Governance plugin is now commercial, you have to registry a license for using it

SonarQube Build Breaker plugin: Report processing did not complete successfully: FAILED

I am trying to upload reports generated by Istanbul to Sonar dashboard using a gulp task and it fails with the below error. Looks like the Build Breaker plugin in SonarQube is timing out before it can upload the report to Sonar. Any way that i can tweak this plugin?
I am using Sonar 5.3.
15:42:43.411 INFO: Analysis report generated in /workspace/{project}/.sonar/report
15:42:43.430 INFO: ------------------------------------------------------------------------
15:42:43.430 INFO: EXECUTION FAILURE
15:42:43.430 INFO: ------------------------------------------------------------------------
15:42:43.430 INFO: Total time: 5:06.287s
15:42:43.609 INFO: Final Memory: 57M/2603M
15:42:43.609 INFO: ------------------------------------------------------------------------
15:42:43.609 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Report processing did not complete successfully: FAILED
at org.sonar.plugins.buildbreaker.QualityGateBreaker.getAnalysisId(QualityGateBreaker.java:152)
at org.sonar.plugins.buildbreaker.QualityGateBreaker.execute(QualityGateBreaker.java:108)
at org.sonar.plugins.buildbreaker.QualityGateBreaker.executeOn(QualityGateBreaker.java:95)
at org.sonar.batch.phases.PostJobsExecutor.execute(PostJobsExecutor.java:65)
at org.sonar.batch.phases.PostJobsExecutor.execute(PostJobsExecutor.java:55)
This is a known invalid issue: #14 (he problem occurs on the server side, not in Build Breaker mechanism/logic).
Matthew DeTullio's comment:
This is because the server side background task for your project is
failing. You need to check the logs there and fix that problem first.
The report processing step is when SQ computes the quality gate
status. This plugin simply checks the status computed there, so if
processing fails this plugin will mark the analysis a failure.
In my company we found on the server side:
java.lang.OutOfMemoryError: GC overhead limit exceeded
The reason could be any error in the SonarQube processing of background task.
And the error is very generic like below
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Report processing did not complete successfully: FAILED
In my case, the server on which SonarQube is installed, ran out of disk space hence it was not able to write the logs.
So, the idea is to check sonar.log to understand whats wrong and rectify it, restart SonarQube service.
less <SONAR_INSTALL_DIR>/logs/sonar.log
2021-03-28 01:13:25,124 elasticsearch[sonarqube][management][T#3] ERROR An exception occurred processing Appender file_es org.apache.logging.log4j.core.appender.AppenderLoggingException: Error writing to stream /apps/sonarqube-8.3.0.34182/logs/es.log
Reboot the Sonar service
cd <SONAR_INSTALL_DIR>/bin
./sonar.sh stop
./sonar.sh start

Resources