not possible to send email after junit set build to UNSTABLE

8 views
Skip to first unread message

ka51m1r

unread,
Jan 8, 2018, 9:00:02 AM1/8/18
to Jenkins Users
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 
Reply all
Reply to author
Forward
0 new messages