Jenkins Pipeline Teststatus Return

Ranorex Spy, Recorder, and Studio.
semate
Posts: 13
Joined: Tue Jul 03, 2018 7:42 am

Jenkins Pipeline Teststatus Return

Post by semate » Wed Dec 12, 2018 11:37 am

Hi everyone!

I'm using a Jenkins pipeline to run my Ranorex test. I would like Jenkins to display the Ranorex test result in the following colors:
Green - all tests passed
Yellow - one or more warnings occured
Red - one or more tests failed
Green and Red I figured out with the script below. I was hoping warnings would cause a return code I could use. But doesn't look like it.
Is there a way to get the warnings out the Ranorex executable? Or do I have to parse the report data xml?

Code: Select all

node('MyNode'){   
    stage ("Execute Test"){
        try{
            bat ("myApp.exe /rc:NightlyBuildDev /rf:Reports/myApp_Report_%BUILD_NUMBER% /zr /zrf:myApp_Report_%BUILD_NUMBER%.rxzlog /ju /pa:paramTestlocation=MyNode_Jenkins")
            echo "Success - Prepare report"
            echo "buildnumber is ${BUILD_NUMBER}"
            step([$class: 'JUnitResultArchiver', allowEmptyResults: true, keepLongStdio: true, testResults: 'Reports\\myApp_Report_${BUILD_NUMBER}.rxlog.junit.xml'])            
            archiveArtifacts 'Reports\\myApp_Report_${BUILD_NUMBER}.rxzlog'            
        }
        catch (Exception err)
        {
            echo "Execution Error: ${err}"            
            archiveArtifacts 'Reports\\myApp_Report_${BUILD_NUMBER}.*'
            mail to: '[email protected]', subject: "Failed Pipeline: ${currentBuild.fullDisplayName}", body: "Test Failed ${env.BUILD_URL}"
            currentBuild.result = 'FAILURE'
        }
    }
}
BTW: Does anybody know why the bat call causes an exception if the test fails (or is this only my test)?
My first attempt was to use:

Code: Select all

post { 
	success { 
		// do good stuff
		}
	failure{
		// start crying
	}
}
but didn't get it to run.

Thanks!

zivshapirawork
Posts: 65
Joined: Wed Sep 24, 2014 7:47 am
Location: Israel

Re: Jenkins Pipeline Teststatus Return

Post by zivshapirawork » Mon Dec 17, 2018 8:15 am

Hi semate

you need to parse the report using

step([$class: 'XUnitPublisher', thresholds: [[$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: '0', unstableNewThreshold: '', unstableThreshold: '']],tools: [[$class: 'NUnitJunitHudsonTestType', pattern: 'xxxxxreportxxxxx.xml', skipNoTestFiles: true]]])