I am working on a project and have successfully run the build script on the source code.
I am able to run sourcemeter successfully and able to run sonar-runner successfully. But the output in the SonarQube dashboard does not show all the files indexed during sonar-runner run. It looks like over 26,000 files have been excluded.
During the execution of sonar-runner, I see that
13:15:42.366 INFO - 26842 files indexed
but when it completes, I get:
13:55:01.504 INFO - 67 files indexed
How can I configure Sonar, so that it indexes all files?
Related
I am using the SonarQube Gradle plugin version 3.0 with Gradle 6.7.1 for analysis of my Java code. This works fine and the results are uploaded to Sonar. When I do gradlew clean test sonarqube initially I have no problem. But when I run it subsequently I get the following:
java.io.IOException: Unable to delete directory 'C:\xxx\build'
Failed to delete some children. This might happen because a process has
files open or has its working directory set in the target directory.
- C:\xxx\build\sonar\findbugs\findsecbugs-plugin.jar
- C:\xxx\build\sonar\findbugs
- C:\xxx\build\sonar
This keep on failing until I kill the Gradle daemon after which I can successfully run sonarqube again.
Is there a way to get around this?
I want to generate a unified report by merging the results from two separate Jenkins maven projects (and I've read that Allure does support that feature - to merge results different allure-results folders), but it does not work properly as I'll explain below.
My objective is to have visibility from all tests results I've from all projects. Currently I can only see the test results specific to a project.
This is the context:
I've two Maven projects (for testNG) running and reporting results via allure on JENKINS. As you can see below, the allure results from those two builds are working as expected - automatically generated by Allure Jenkins plugin version 2.26.0
Allure Jenkins plugin working fine for separate maven jobs
Now I've also installed the Allure 2.6.0 and added it on system PATH and properly configure ALLURE_HOME environment var.
So when I ran this command here:
allure serve "C:\Users\tester\workspace\scripts-qa\STF\allure-results" --host "127.0.0.1" --port "8081"
It works perfectly to report the results in my Allure-results from my IntelliJ, as you can see below.
Allure serve results from my local worspace
Now when I ran similar command as above one to generate a unified report by merging both reports I got in Jenkins - just the execution trend is been populated - but the total number of tests and its details are not as you can see below.
This is the command I'm executing to generate a unified report:
allure serve "C:\Users\tester\.jenkins\workspace\Regression2\allure-report" "C:\Users\tester\.jenkins\workspace\Regression1\allure-report" --host "127.0.0.1" --port "8081"
Allure problem when trying to merge reports from two separate jenkins projects
Could you please help me to figure out what is wrong here? Is that possible that allure binary cannot serve results generated by allure Jenkins plugin? If yes, what is the work around to fix that?
Thank you!!
Jean.
I can see that you are trying to generate cumulative report from already generated reports, which is not correct - Allure needs raw allure-results to generate report
As a workaround, you need
Archive allure-results for each test execution job and attach it to build as artifact
Copy allure-results artifacts
Unzip it
Build a report based on allure-results from artifacts
Below are code snippets for Pipeline job
Attach allure-results as artefact:
zip archive: true, dir: "target/allure-results", glob: '', zipFile: "allure-results.zip"
Copy artefacts to another job:
copyArtifacts filter: 'allure-results.zip', optional: true, projectName: "Regression1", selector: lastCompleted(), target: "Regression1"
unzip dir: "Regression1", glob: '', zipFile: "Regression1/allure-results.zip"
...
Build report
allure serve Regression1 Regression2
You can also select reports for aggregation like this:
allure includeProperties: false, jdk: '', results: [
[path: '../name-of-job-1/target/allure-results'],
[path: '../name-of-job-2/target/allure-results'],
[path: '../name-of-job-3/target/allure-results']]
}
I try to use the generic test plugin. I have the unittest.xml file with an absolute path
<file path="/Users/emerson/dev/sonar/project/workspace/components/triage/src/assets/test/unit/tests/controllers/controller.coffee">
the coffee script got compiled into js and unit tests were executed with the unittest.xml as result.
When I add this to my sonar build via the sonar.genericcoverage.unitTestReportPaths, it does recognise the unittest.xml, but does nothing.
The log says
[sonar:sonar] 14:32:55.108 INFO - imported unit test data for 0 files
[sonar:sonar] 14:32:55.109 INFO - unit test data ignored for 1 unknown files, including:
and then the path to the file named in the unittest.xml
The path is valid, why does it not recognise it ? Neither the coffee script nor the compiled js are part of the sonar build, is it therefore ?
As there is no support of coffee script with sonar, my hope was to at least include the unittest results in sonar.
Can someone explain whether it is possible and what should be written into the path field in the unittest.xml ?¨
Thanks for any clarification
Indeed the files need to be indexed in SonarQube in order to import test data.
You can set sonar.import_unknown_files to true with SonarQube 5.1+ to have all files indexed by SonarQube.
http://docs.sonarqube.org/display/SONAR/Analyzing+Source+Code#AnalyzingSourceCode-Unrecognizedfiles
I’m integrating SonarQube in our build system – I installed sonar-runner-2.4 on our build agents and added the sonar-runner.properties for each solution (to the solution’s folder on TFS).
When running the build I’m executing the sonar-runner after the solution has been compiled on the build agent.
Everything seem to work except for the unit test:
On the build’s log I see that almost 200 tests ran and were completed successfully and in the sonar-runner log I see the following:
14:23:29.808 INFO - 583/583 source files analyzed
14:23:30.809 INFO - Sensor org.sonar.plugins.csharp.squid.CSharpSquidSensor#1a50b87 done: 14937 ms
14:23:30.809 INFO - Sensor org.sonar.plugins.csharp.core.CSharpUnitTestResultsProvider$CSharpUnitTestResultsImportSensor#97edbc...
14:23:30.821 INFO - Sensor org.sonar.plugins.csharp.core.CSharpUnitTestResultsProvider$CSharpUnitTestResultsImportSensor#97edbc done: 12 ms
Which seems ok I guess, but when logging into the sonar server it shows that 0 tests ran.
On the sonar-runner.properties file I set the following value to
sonar.cs.vstest.reportsPaths:
sonar.cs.vstest.reportsPaths=TestResults/*.trx
when in this case there are 3 vstest trx files located in the following local path on the build agent: `
D:\sTFS\22965\Sources\TestResults
` (see TestResults.jpg attached).
Attached is the sonar-runner.properties file.
I also attached a screen capture from the sonarqube server (see SonarServer.jpg attached).
Can you please advise what might be the problem?
You should be seeing some messages like:
INFO - Parsing the Visual Studio Test Results file ...
for each unit test result file that is being parsed, see VisualStudioTestResultsFileParser.java#L34
Can you try to pass an absolute path pattern to sonar.cs.vstest.reportsPaths? My guess is that the issue comes from the relative path.
By the way, the use of the sonar-runner to analyze .NET projects is being deprecated. You'll want to have a look at the MSBuild SonarQube Runner that offers very good integration with Team Foundation Server. See the new C# plugin documentation on SonarSource's Wiki: http://docs.sonarqube.org/display/PLUG/C%23+Plugin
EDIT
I just noticed the package name from your logs org.sonar.plugins.csharp.core.CSharpUnitTestResultsProvider. The .core. was present only in outdated versions of the C# plugin (in the 3.x series), and these versions might not support wildcards in report paths. Please upgrade to the latest version.
I have a project Pensky with two build Jobs on my Jenkins Server. The First Build job does maven build and collects JaCoCo Code coverage report on Post Build Action.
My Second Build Job runs Sonar Analysis on my project. I would like to reuse/feed the JaCoCo code coverage report into my Sonar. But, unable to do so. I see the below message in my build job console
"Project coverage is set to 0% as build output directory does not
exist:"
The sonar job is looking for 'classes' folder in the .sonar directory (in the jenkins job directory).
Can anyone guide me how to feed the report into Sonar. Thank you
This is my sonar.properties
sonar.projectKey=Pensky
sonar.projectName=Pensky
sonar.projectVersion=1.1
sonar.projectDescription= GE Pensky
sonar.sources=src/main/java
sonar.tests=src/test/java
sonar.language=java
sonar.my.property=value
sonar.forceAnalysis=true
sonar.jacoco.reportPath=target/jacoco.exec
You haven't set the "sonar.binaries" property to point to the build directory (= "target/classes" if you compile it with Maven).
First of all, you should to copy the folder target of the first job in order to save time. If you do that, you have in the workspace of the job, all the binaries and the jacoco.exec file.
Then, you have to set the folder of the tests result.
sonar.junit.reportsPath=target/surefire-reports(or other)
sonar.jacoco.ReportPath=target/jacoco.exec
And finally, you have to set the binaries folder.
sonar.binaries=target/classes
Hope I have been helpful.