[Declarative Pipeline] currentBuild.result is not set

763 views
Skip to first unread message

Dan Tran

unread,
Feb 11, 2017, 12:49:01 PM2/11/17
to Jenkins Users

Hi

It seems currentBuild.result is not set at post stages, here is the snippet. is it normal?  it always return null for my case

   stages {
      ...
    }

    post {

        always {
script {
           wrap([$class: 'BuildUser']) {
                      mail to: "${env.BUILD_USER_EMAIL}",
                          subject: "${env.BUILD_URL} ${currentBuild.result}",
                              body: "${env.BUILD_URL} completed"
                           }
                       }
        }

    }

Thanks

-Dan

Andrew Bayer

unread,
Feb 12, 2017, 1:42:02 AM2/12/17
to jenkins...@googlegroups.com
Yup - currentBuild.result isn't actually set until either something is explicitly setting the status (like a failure or unstable) or the build ends, at which point it's set to success if still null. So basically null is equivalent to success.

A.

--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ce8101b2-6a0b-4581-a39b-5b831339d62f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dan Tran

unread,
Feb 12, 2017, 2:08:19 AM2/12/17
to Jenkins Users
Thanks that helps

-Dan
Reply all
Reply to author
Forward
0 new messages