How to use ${currentBuild.result} to indicate "SUCCESS" not "null" How to use ${currentBuild.result} to indicate "SUCCESS" not "null" jenkins jenkins

How to use ${currentBuild.result} to indicate "SUCCESS" not "null"


Use ${currentBuild.currentResult} instead.

currentResult

typically SUCCESS, UNSTABLE, or FAILURE. Will never be null.

The syntax of the available global variables is available at ${YOUR_JENKINS_URL}/pipeline-syntax/globals. See more info about globals in Jenkins documentation.

Also see https://issues.jenkins.io/browse/WEBSITE-364


You can add mail step inside post step in pipeline as below :

pipeline {agent anystages {    stage('Example Test') {        steps {            echo 'Hello, JDK'        }       }     }post { success {     echo "${env.BUILD_URL} has result success"      } failure {     echo "${env.BUILD_URL} has result fail"      }     } }