Jenkins NUnit publishing access test results - jenkins

I recently tried to add a "Publish test results" step within my Jenkins pipeline, but was wondering where to see/retrieve the TestResults.xml file that should be generated while deploying.
For reference, here's the code I'm using, straight from the documentation:
stage("Publish NUnit Test Report") {
steps {
nunit testResultsPattern: 'TestResult.xml'
}
}
Thanks a lot for your help!

Related

How to integrate Taurus with Jenkins?

I created a yaml file and I would like to run Taurus test using Jenkinsfile.
I tried with these :
stage("run test") {
bzt "stepping.yml"
}
But i am receiving an error regarding bzt.
It would be better if you show an error message
BTW, You can also check these to guide you to integrate Jenkins with Taurus
https://gettaurus.org/kb/Jenkins/
https://www.blazemeter.com/blog/how-run-taurus-test-through-jenkins-pipelines

How manage to get an automated build server with jenkins for projects in Delphi

In a nutshell, how manage to get an automated build server with jenkins or other, to build several Delphi's projetcs using MSBuild?
I am currently a trainee in a company. I have managed to find a solution to migrate and change the old SCM software : PVCS to SVN. But they are using old shell scripts and Cygwin to build with several options to compile/release all or certain Delphi projects and produce DLL and EXE. I wanted firstly to use Jenkins to try to reproduce the same mechanism, but I am not sure it is the best way to deal with this. I have tried to set a free-style job and a multibranch pipeline. The first is ok to build one project but the latter is not a success, I don't know groovy...
I am not interested in the test part of the continuous integration I just want to have an automated build for several Delphi projects.
I don't know how to deal with this. Maybe the best way is to make as much as jenkins' jobs as there is delphi's projects? But how to control them after?
I have read about Maven and Ant but I am not sure it is relevant in my case.
Any advices are welcomed
You can create simple jobs "free-style job" or "pipelines". The pipelines are more powerful, but more complicated if you are starting.
You can start by creating a Job for each project. Then you can chain projects with different jenkins options. When a Job finish the other job start. See image following image.
You can also use to compile an existing plugin for existing RAD Studio for Jenkins. Use it in "free-style job".
The other option is to use pipelines, but you should know something about Groovy.
For example, a simple pipeline with several steps would be this:
pipeline {
agent any
stages {
stage('Stage: Show message Hola Mundo') {
steps {
echo 'Paso 1. Hola Mundo'
}
}
stage('Download source from GIT') {
steps {
echo 'Downloading...'
git([url: 'https://XXX_repository_xxxx.git/gitProject', branch: 'master', credentialsId: 'a234234a-344e-2344-9440-423444xxxxxx'])
}
}
stage('Executing MSDOS file (BAT)') {
steps {
echo '-- Sample Executing BAT file'
bat '"c:\\Program Files (x86)\\Embarcadero\\Studio\\19.0\\bin\\rsvars.bat"'
}
}
stage('MSBuild a Delphi project') {
steps {
println("************ EXECUTING MSBUILD ******************")
echo '-- Lanzar la ejecuciĆ³n de rsVars ---------'
bat '"c:\\Program Files (x86)\\Embarcadero\\Studio\\19.0\\bin\\rsvars.bat"'
echo '-- MSBuils del proyecto TestLauncher -------'
bat '"c:\\local\\AutomaticTestsProject\\compilar.bat"'
}
}
stage('Execute a test project (EXE)') {
steps {
bat 'c:\\local\\AutomaticTestsProject\\BIN\\AutomaticTestsProject.exe'
}
}
stage('Send emeil') {
steps {
emailext (
subject: "Job '${env.JOB_NAME} ${env.BUILD_NUMBER}'",
body: """<p>Check console output at ${env.JOB_NAME}</p>""",
to: "destinatary#hotmail.com",
from: "JenkinsMachine#mail.com" )
}
}
}
}

using multiple JUnit results file on Jenkins pipeline

On my Jenkins pipleline I run unit tests on both: debug and release configurations. Each test configuration generates separate JUnit XML results file. Test names on both: debug and release configuration are same. Currently I use the following junit command in order to show test results:
junit allowEmptyResults: true, healthScaleFactor: 0.0, keepLongStdio: true, testResults: 'Test-Dir/Artifacts/test_xml_reports_*/*.xml'
The problem is that on Jenkins UI both: debug and release tests results are shown together and it is not possible to know which test (from debug or release configuration) is failed.
Is it possible to show debug and release tests results separately? If yes, how can I do that?
We run the same integration tests against two different configurations with different DB types. We use maven and the failsafe plugin, so I take advantage of the -Dsurefire.reportNameSuffix so I can see the difference between the two runs.
The following is an example block of our Jenkinsfile:
stage('Integration test MySql') {
steps {
timeout(75) {
sh("mvn -e verify -DskipUnitTests=true -DtestConfigResource=conf/mysql-local.yaml " +
"-DintegrationForkCount=1 -DdbInitMode=migrations -Dmaven.test.failure.ignore=false " +
"-Dsurefire.reportNameSuffix=MYSQL")
}
}
post {
always {
junit '**/failsafe-reports/*MYSQL.xml'
}
}
}
In the report, the integration tests run against mysql then show up with MYSQL appended to their name.
It looks no solution for my question.
As a workaround I changed JUnit XML report format and included build variant name (debug/release) as a package name.

How can I publish NUnit test results using Jenkins Pipeline?

Trying to use the nifty Jenkins Pipeline, I had problems finding out how to publish NUnit test results.
I am able to run the tests by specifying the following command in the pipeline script:
stage 'Test'
bat '"C:\\Program Files (x86)\\NUnit 2.6.4\\bin\\nunit-console-x86.exe" "ProjectName\\bin\\Release\\UnitTests.net.dll"'
But how to make Jenkins "publish" the test results is not obvious. The Snippet Generator only suggests junit, and that does not seem to work.
I used nunit plugin version 0.21 and was able to publish results using
stage("PublishTestReport"){
nunit testResultsPattern: 'TestResult.xml'
}
(TestResult.xml is at the root of jenkins workspace in this above example)
Investigating the NUnit plugin for Jenkins led me on to this issue, where I found the solution:
step([$class: 'NUnitPublisher', testResultsPattern: 'TestResult.xml', debug: false,
keepJUnitReports: true, skipJUnitArchiver:false, failIfNoResults: true])
Adding this to the pipeline script worked for me!
However, it seemed the following should also work (but at the present, apparently, it does not): Using the Snippet Generator, select this:
step: General Build Step
Publish NUnit test result report
This generates the following in the Pipeline script:
step <object of type hudson.plugins.nunit.NUnitPublisher>
This fails!

Jenkins Pipeline Test Results Analyzer Support

It looks like support for test results analyzer was added to the pipeline plugin from the jira issue below. I'm having trouble figuring out how to acutally implement the plugin using a pipeline script.
https://issues.jenkins-ci.org/browse/JENKINS-30522
Regardless of the jira issue, how can I run the test results analyzer through my pipeline?
When you add test reports to your pipeline script this works automatically. The "Test Results Analyzer" button shows up right away for jobs that have tests, including those that use the pipeline plugin.
For example when using the standard "junit" report plugin like this, it should work out of the box:
stage('Unit tests') {
steps {
sh 'unit-tests.sh'
}
post {
always {
junit 'path/to/report.xml'
}
}
}

Resources