Make a test result intentionally unstable

12 views
Skip to first unread message

Christoph Fetzer

unread,
Jun 4, 2020, 8:04:23 AM6/4/20
to Jenkins Users
Hello!

I have a unit test that from time to time deadlocks. To work around that and at least finish the build and collect the results available so far I made use of a timeout in a try and caught the timeout. When this timeout applies now, I get an overall green testrun which is not what I want. When I want so set the test result to 'unstable' either by calling 'unstable' or by setting the result to the string 'UNSTABLE' I still get a succeeded run.

This is my script code, called from a declarative pipeline from the build stages of severak modules/libraries in a build:

try{                                        
    timeout
(time: 60, unit: 'MINUTES') {                
        bat
"""                
            rem call my test from here
            """

   
}
} catch (err) {
    echo
"Caught: ${err}"
   
//currentBuild.result = 'UNSTABLE';
    unstable
( message: "Test timeout in stage ${STAGE_NAME}" )
}

Any ideas whats wrong here?
Regards,
Christoph

Reply all
Reply to author
Forward
0 new messages