As far as I see "currentBuild.getCurrentResult()" is not null even though 
when no set was explicitly set, this is my snippet and console output

pipeline {
    agent any
    stages {
        stage ('release') {
            steps {
                script {
                    echo "echo currentbuild ${BUILD_ID}"
                    //sh 'exit 1'
                }
            }
        }
    }
    post {
        changed {
            script {
                echo "${currentBuild.getCurrentResult()}"
                if (currentBuild.resultIsBetterOrEqualTo('SUCCESS')) {
                    echo "Previous build failed 
${currentBuild?.getPreviousBuild()?.number} and now it has been fixed"
                }
            }
        }
    }
}

[Pipeline] nodeRunning on master in 
/var/jenkins_home/workspace/_scratch/test_def[Pipeline] {[Pipeline] 
stage[Pipeline] { (release)[Pipeline] script[Pipeline] {[Pipeline] echoecho 
currentbuild 37[Pipeline] }[Pipeline] // script[Pipeline] }[Pipeline] // 
stage[Pipeline] stage[Pipeline] { (Declarative: Post Actions)[Pipeline] 
script[Pipeline] {[Pipeline] echoSUCCESS[Pipeline] echoPrevious build failed 36 
and now it has been fixed[Pipeline] }[Pipeline] // script[Pipeline] }[Pipeline] 
// stage[Pipeline] }[Pipeline] // node[Pipeline] End of PipelineFinished: 
SUCCESS


Cheers

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/94b93b0a-cf6e-4210-a459-a60019560bcd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to