Running SonarQube scanner sonar-web-frontend IlligalStateException - sonarqube

I am running the SonarScanner using the sonar-web-frontend-plugin from the commandLine, it picks up the files and runs and I get an execution Failure
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Report processing did not complete successfully
: FAILED
My sonar-project.properties look like this
# must be unique in a given SonarQube instance
sonar.projectKey=Test.UI
# this is the name displayed in the SonarQube UI
sonar.projectName=Test.UI
sonar.projectVersion=1.0
# Comma-separated paths to directories with sources (required)
sonar.sources=src/app
# exclude some files and folders (typically dependencies)
sonar.exclusions=bower_components/**/*, node_modules/**/*
# Encoding of the source files
sonar.sourceEncoding=UTF-8

You have the Build Breaker plugin installed on your SonarQube instance.
Your project failed its quality gate.
The Build Breaker plugin did its job, and "broke" (returned a non-success status code) your build.

Seems like it was because i had the default JS rules still installed and they can't exist side by side.

Related

SonarCFamily only detects code-smells duplicate code blocks

I'm trying to use SonarScanner with SonarCFamily plugin on my C codebase on ubuntu. I see that the scanner is able to only detect "code smells - duplicate blocks of code" in my codebase and no other forms of bugs/vulnerabilities. I intentionally added a memory leak in the code and SonarQube couldn't detect it while open source SA tool Cppcheck was able to. Am I missing some setting in the sonar-project.properties file ? My sonar.properties file is as follows. Are there any settings needed in the server/SonarCFamily plugin for the tool to detect other forms of SA errors ?
# must be unique in a given SonarQube instance
sonar.projectKey=c-sa-test
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=c-sa-test
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
sonar.sources=src
# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
sonar.host.url=http://localhost:9000
sonar.cfamily.build-wrapper-output=bw_output
sonar.c.file.suffixes=.c,.h
sonar.cpp.file.suffixes=.cc,.cpp,.cxx,.c++,.hh,.hpp,.hxx,.h++,.ipp
Found the root cause - Was missing providing some elements of the project build process as input to the build wrapper. Once those were added, SonarQ provided a detailed report.
I had the exact same problem where SonarCFamily was only reporting code duplications. It was due to an incorrect build process as input to the build wrapper. In my case, I was using SonarScanner.MSBuild and on my build-wrapper line, I didn't have the Configuration and Platform specified, so my projects were not getting built or scanned. The final working lines were:
SonarScanner.MSBuild.exe begin /k:"your key" /d:sonar.cfamily.build-wrapper-output=”bw_output”
build-wrapper-win-x86-64.exe --out-dir bw_output MSBuild.exe your_solution.sln /p:Configuration=Release /p:Platform=x64
SonarScanner.MSBuild.exe end

Unable to scan Cobol project using SonarQube

I am trying to workout code analysis for my COBOL code with SonarQube. I installed sonarcobol plugin and using sonarscanner I am trying to check for analysis. when I do sonar-scanner in respective directory, it says success but unable to see analysis in SonarQube server.
Attached is my sonar-project.properties
sonar.host.url=http://xxxxx:9000/
sonar.login=admin
sonar.password=admin
sonar.projectKey=cobol
sonar.projectName=cobol
sonar.projectVersion=1.0
sonar.sources=.
sonar.sourceEncoding=UTF-8
## Cobol Specific Properties
# comma-separated paths to directories with copybooks
sonar.cobol.copy.directories=copybooks
# comma-separated list of suffixes
sonar.cobol.file.suffixes=cbl,cpy
sonar.cobol.copy.suffixes=cpy
## Flex Specific Properties
# retrieve code coverage data from the Cobertura report
#sonar.flex.cobertura.reportPath=coverage-report/coverage-cobertua-flex.xml
# PL/I Specific Properties
sonar.pli.marginLeft=2
sonar.pli.marginRight=0
from the Author's comment above:
I solved this by adding sonar.languages=COBOL in sonar-project.properties
Pasting here for convenience.

No LOC or Bugs picked up by SonarQube runner

I am using sonar-web-frontend-plugin
I have the following sonar-project.properties file which is located at this path
E:\agent2\test\sonar-project.properties
sonar.projectKey=Test
sonar.projectName=Test
sonar.projectVersion=1.0
sonar.sources=src/app
sonar.sourceEncoding=UTF-8
I have my source code in the following location
E:\agent2\test\src\app
My runner is located here
E:\agent2\test\.sonarqube\bin\sonar-scanner-2.8\bin\
and I am running the following in cmd E:\agent2\test>
E:\agent2\test\.sonarqube\bin\sonar-scanner-2.8\bin\sonar-runner -Dproject.settings= E:\agent2\test\sonar-project.properties -X
It is all running fine but no issues are being reported and no LOC are being picked up in the log it says the following
Calculating CPD for 0 Files
So it does not actually seems to analyse anything, I know there are issues because when i run TSlint locally i get issues found
Your analysis setup looks okay.
It is very likely that you don't have the relevant language plugin installed on your SonarQube instance. Either that, or your code is contained in files with unrecognized extensions.
Each language plugin tells SonarQube scanner "I'm interested in files with these extensions:..."
The fact that the analysis is over "0 Files" indicates that no file extensions were recognized.

Failed to publish TestNG Report in Jenkins

I have used Maven project with Selenium & TestNG to create automated scripts which I want to execute from Jenkins. In Jenkins I have added the TestNG plugin to publish the TestNG report. But it is not getting displayed. I'm getting the below mentioned error.
Error:
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: /target/surefire-reports/testng-results.xml
Did not find any matching files.
Finished: SUCCESS
Actual path of the TestNG report file:
E:\STUDY_MATERIAL\JAVA\WORKSPACE\SeleneniumFrameWork\target\surefire-reports\testng-results.xml
I have tried the following options but didn't work out for me.
Tried giving the full path of the TestNG report. Forward ans backward slash in the pattern.
I have tried different other options by changing the TestNG result file path but it's working for me.
Please share some inputs on how to resolve this issue.
"testng-results.xml" file is available in workspace. But it's failed to display the report. I have attached screenshot of Jenkins workspace and Console Output.
Note: I am using Jenkins 2.7.0 in Windows 10.
Jenkins Workspace
I have attached the Job configuration details of Jenkins.
Job Configuration Details
Few checkpoints :
1. Check if testng is producing this file at the specified location : /target/surefire-reports/testng-results.xml
2. TestNG needs to be configured to generate xml report
If this file is there, pass path in file locator as :
target/surefire-reports/testng-results.xml
Hopefully, you will get results on jenkins if everything mentioned above is correct.

JavaScript Unit Tests not working on SonarQube

I have below problems with SonarRunner.
SonarQube along with Sonar runner unable to pull junit format xml reports
Unit Tests or Test Coverage widget doesn't show up. It says No Data.
I am following instructions described here
I manually created report file in XML format as described, but still no luck.
Below is the XML file - TEST-Firefox_210_Mac_OS.com.company.BarTest.xml,
<testsuite name="Firefox_210_Mac_OS.com.company.BarTest" errors="0" failures="0" tests="3" time="0.0">
<testcase classname="Firefox_210_Mac_OS.com.company.BarTest" name="testfullName" time="0.0"/>
</testsuite>
To pull the Unit Test execution report to show on sonar dashboard. I have used sample git project from here
and below is my sonar-project.properties,
# project metadata (required)
sonar.projectKey=org.codehaus.sonar:javascript-sonar-runner-jstestdriver
sonar.projectName=JavaScript project with Sonar Runner reusing reports generated by JsTestDriver
sonar.projectVersion=1.0
# path to source directories (required)
sonar.sources=C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/sources
# path to tests source directories (required)
sonar.tests=C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/tests
sonar.javascript.jstestdriver.reportsPath=C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/target/TEST-Firefox_210_Mac_OS.com.company.BarTest.xml
sonar.sourceEncoding=UTF-8
below is my jsTestDriver.conf
server: http://localhost:9876
load:
- C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/sources/*.js
- C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/sources/com/company/*.js
test:
- C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/tests/*.js
- C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/tests/com/company/*.js
plugin:
- name: "coverage"
jar: "coverage-1.3.5.jar"
module: "com.google.jstestdriver.coverage.CoverageModule"
My sonarqube is running on port : 9000 and below is the screen shot. As you see SonarRunner and jsTestDriver just doing a code analysis and not showing any unit tests.
SonarQube doc website says jsTestDriver will run the javascript unit
tests and copy the results in target folder in XML format
SonarQube doesnt run your Unit Tests, it just gathers the reports generated from your manuall run or other tools automatic run (like: Jenkins).
From SonarQube doc:
Prior to the SonarQube analysis, execute your unit tests in order to
generate XML report. The JUnit like XML format supported is the one
generated by js-test-driver
Then I manually created report file in XML format as described, but
still no luck.
If you created manually the report files and reports are still not showing, check your paths if ok.Check if sonar is really reading data from C:/Sonar/sonar-runner-dist-2.4/sonar-runner-2.4/projects/ path

Resources