Cannot generate unified Allure report from two separate Jenkins maven builds - maven

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']]
}

Related

sonar-runner excluding files

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?

Jacoco Session created Exed shows no Coverage on Sonarqube

I created a Exec via JacocoAgent on my Local machine (For IT-Testing). Now when I try to upload this Exec to sonarqube, it shows no Coverage.
I built an Ant Task which created an html Report and there I saw, that there was definetely coverage generated. I saw it also in the Jacoco Plugin for Eclipse.
Any Suggestions ?
To execute Sonaranalysis I use Gradle with the "sonar.jacoco.reportpaths" property.
The Log says it is able to read the file (I tried it with the exec, which was generated by Unit Tests and it worked)

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

Jenkins + Sonar

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.

Resources