not possible to send email after junit set build to UNSTABLE

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

not possible to send email after junit set build to UNSTABLE

ka51m1r
Hi everybody,

we are currently working on the pipelines for our build environment. 
In our old job, the job was set to unstable, if the junit report plugin find some failing tests in the results and send an email to a specific user group. 
Please have a look to the added screenshot for the old configuration.

Now we have the problem, that we do not get an email if the build gets unstable in the pipeline.
It seems that the pipeline do not now that the step was failing, because the currentBuild.result is still null.
After the build, the build Status in Jenkins is UNSTABLE, but during the pipeline it is null.

Here is my pipeline code:
...
        stage("Junit Report Step") {
       steps {
                junit healthScaleFactor: 1.0, testResults: 'junit/TEST-*.xml'
            }
            post {
                always {
                echo "Result: ${currentBuild.result}" // result = null
                }
            }
        }

        post {    
           always {
           echo "Result: ${currentBuild.result}" // result = null

            // no mail will be send
             step([$class: 'Mailer',
             notifyEveryUnstableBuild: true,
             recipients: "xxx",
             sendToIndividuals: true])
          }
       }

Is there a way to read the state after the junit plugin has set the status to unstable? Is there any way to send a mail notification, if the junit task set the build to unstable?

Thanks,
ka51m1r 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/8655a24a-901c-4d1e-a764-94793f8ff7a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.