Publishing JUnit results from Jenkins to SonarQube not on same server - jenkins

I've got the following setup:
server 192.168.0.xxx running Jenkins 1.643
server 192.168.0.yyy running SonarQube 5.2 (with Java 1.8.0_66)
server 192.168.0.zzz running PostgreSQL as SonarQube DB (FYI)
I want Jenkins to run a SonarQube analysis on a specific project. I therefore created a job with goal sonar:sonar -Dsonar.host.url=http://192.168.0.yyy. Everything's working well except for code coverage in SonarQube. It says there's a coverage of 0,0 % although there are several tests run by Jenkins.
So I'm pretty sure test results are not published to SonarQube. Google brought me to solutions exporting the results to a directory on the same server and telling SonarQube this directory via -Dsonar.junit.reportsPath.
But this solution is not that easy to implement having Jenkins and SonarQube not on the same server. Long story short: is there another way publishing JUnit test results to SonarQube?

The report path should point to a directory where the analysis is run not on the sonarqube server
So when you are running the sonar:sonar command just use the -Dsonar.junit.reportsPath to point to the the directory containing the report of unit test execution and you should be fine.

Related

how could i publish sonarqube report in jenkins? using the sonarqube portlet

I have configured sonarqube for one of my projects, but now i want to publish the sonarqube details in my jenkins dashboard. what could be the best possible way to do that?
I'm not sure that there is a straight forward way of getting "all" the data from sonar on to your Jenkins dashboard but can actually get a sonar badge and Quality gate info by using the Sonar plugin for Jenkins.
https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-jenkins/?q=cache:Tbhy8757pK4J:https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-jenkins/+&cd=1&hl=en&ct=clnk&gl=us
First of all, you need to deploy sonarqube on your local machine, ones it is done, then copy the URL of your sonarqube server, I am assuming, you have deployed sonarqube server on port 9090, once this done, log in to the sonarqube server and then create a project and then generate a token for that project:
Once these above configuration is done, just hit below maven command to generate sonarqube report on the sonarqube server:
mvn sonar:sonar -Dsonar.projectKey=[projectName] -Dsonar.host.url=http://localhost:9090 -Dsonar.login=[tokenId]
Below is the screenshot, this is how your reports on the sonarqube will looks like:

Jenkins: how save the logging outputs saved through Gradle testing into Jenkins Build History

I am working with:
Jenkins 2.64
Gradle 3.5
Spring Framework 4.3.8
I am able to execute a Main java class through a Gradle task through Jenkins.
Therefore I can execute a Job N times to work around JMX and for each Job execution I have the Build History where I am able to see the logging outputs from my business classes for each interaction.
Note the history saves each logging outputs for each Job's execution
The problem is with testing.
Through Jenkins I am able to execute a Job related with a Gradle Test command, such as: gradle test --tests. Here two behaviors:
Gradle saves the logging outputs from my business classes through its own output directory build\reports\tests\test (it is the expected, I am fine with this)
Jenkins worked fine about the execute the Gradle test command but all the logging outputs are only posted through the Gradle Test reports but not in Jenkins, it in Build History.
Thus the Jenkins does not contain the logging outputs from my business classes. Therefore if I execute N times through my developing cycle the Test Job. I only am able to see the latest logging outputs only through the Gradle Test Reports, sadly Jenkins does not keep these logging outputs through Build History.
How resolve this? Some basic configuration or a plugin is need it?
In order to save junit reports in Jenkins, you can use JUnit Plugin
Individual reports are located at build/test-results/test/.xml*
If you are using Declarative Pipelines you can use the following script
junit 'build/test-results/test/*.xml'
Since you are pointing to build\reports\tests\test\index.html which is the gradle test report, you can also save that report using HTML Publisher Plugin
My suggestiong is to use JUnit Plugin for better integration.
To save artifacts from your build you can use the archiveArtifacts pipeline command
It would look something like:
archiveArtifacts artifacts: 'build/reports/tests/test/*'

Configure Jenkins to Execute tests in UFT

I am running UFT Test Suite manually on the host machine, however i now have the requirement to run the smoke tests as soon as the new build is delivered in jenkins. For that i need to run the test suite automatically using Jenkings. Can someone help me in the direction, how this can be achieved? I have never used Jenkins before.
Looks like theres a plugin for Jenkins which enables integration with HP UFT. Take a look at the Jenkins wiki page for instructions about how to install and use it.
As you didn't mention that you are using ALM so I am assuming that you have some kind of driver script in vbs which runs your test suite. You do not necessarily require any plugin in jenkins to run your UFT suite(however you can also check the suggestion given in the previous answer). Create a job in jenkins and call your vbs file (driver file) or a bat file which kicks off your execution your test machine.
Your test execution machine can be configured as jenkins slave. Only thing which you need to take care off is to remove the settings which can let go your jenkins slave machine which is your uft execution machine in standby mode or locked user mode(uft scripts will fail otherwise). You can handle this by configuring windows settings(if admin allows) or by using some small scripts to move mouse after some intervals.
Your test execution job in jenkins(master) machine can be made dependent on the job which goes to success when new build is available. As soon as new build is available - that job goes to success then your Test job gets notified and connects to UFT execution machine(slave) and starts running your test.
I am trying to integrate ALM with jenkins but not working
Started by user admin
Running as SYSTEM
Building in workspace C:\JENKINSHOME\workspace\CLRP_AUTO_RN
[CLRP_AUTO_RN] $ C:\JENKINSHOME\workspace\CLRP_AUTO_RN\HpToolsLauncher.exe -paramfile props05092020010832244.txt
"Started..."
Timeout is set to: -1
Run mode is set to: RUN_PLANNED_HOST
Unable to retrieve test set folder: Node not found.
Node not found.
Starting test set execution
Test set name: CLRP Smoke Test Automation Run, Test set id: 104
Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
Could not create scheduler, please verify ALM client installation on run machine by downloading and in installing the add-in form: http://almserver:8080/qcbin/TDConnectivity_index.html
Build step 'Execute Micro Focus functional tests from Micro Focus ALM' changed build result to FAILURE
Finished: FAILURE

JMeter : Maven Build Hangs/Freezes at the end of execution in Jenkins

I am using jmeter-maven-plugin to execute JMeter tests (JMX Files) as a maven project from Jenkins.
What I observed is:
When rampup time is more or virtual user is more, Jenkins freezes the execution towards the end. It keeps on executing for days if not stopped.
When executed outside Jenkins e.g using maven commands directly using cmd, works great. Also when executed directly from JMeter GUI, works fine.
There was an issue with jmeter maven plugin which was fixed in later version.
Solution was made by Abhishek Swain.
See

Do I need sonar and sonar runner for Jenkins?

I want to set up Sonar with Jenkins. But I'm not sure if the Sonar site describes two different ways to do this or if there are two necessary steps:
As far as I understood it, it's two different ways. If this is the case, what is the difference and what are the advantages and disadvantages (between the Sonar itself and Sonar runner)?
If you want to analyse a project with SonarQube and Jenkins, here's what you need:
A SonarQube server up and running
A Jenkins server up and running with the SonarQube Scanner for Jenkins installed and configure to point to your SonarQube server
A job configured to run a SonarQube analysis on your project:
Using the default and standard SonarQube Scanner (suitable for most projects)
Using the SonarQube Scanner for MSBuild (for .NET solutions)
Using a post build action for Maven-based projects
Everything is described more in details on the SonarQube Scanner for Jenkins documentation page.

Resources