How to set current build result in Pipeline?


  • Whenever I print out the field: currentBuild.result it is null. When does this get set or am I supposed to set it?


  • CloudBees Jenkins Enterprise
  • Pipeline


Avoiding setting currentBuild.result manually. Instead use the catchError step in Scripted Pipeline, or a post block in Declarative.

Have more questions?


  • 0
    Kenneth Lamb

    Where can I find a list of valid values for currentBuild.result? I thought it was just a string, but it appears to only allow certain values.

    For example, this code:
       echo "currentBuild.result1: '${currentBuild.result}'"
       currentBuild.result = 'FAILEDZZZZ'
       echo "currentBuild.result1: '${currentBuild.result}'"

    Will yield this:   

    currentBuild.result1: 'null'
    [Pipeline] echo
    currentBuild.result1: 'FAILURE'


  • 3
    Allan Burdajewicz

    Hi Kenneth,

    You are right. currentBuild.result is not a simple String. It is a String representation of hudson.model.Result

    The reason why you see FAILURE when the String does not match a known value is because of this method.


    Edited by Allan Burdajewicz
  • 0
    Kenneth Lamb

    Just what I was looking for. Thank you very much!

  • 0
    Lee Meador

    Just for making it easy there are two other interesting statuses ABORTED and UNSTABLE

  • 0
    Luis a. Del Pozo G.

    Hello everyone :) !!

    I am new to jenkins and groovy and I'm trying to print out using this same example other values such as

    currentBuild.durationString and others, I have followed this example 
    and the one from, trying to print out the currentBuild.durationString
    like result in data, it that possible to do, any suggestions of how can I
    accomplish it?, Any help is really appreciated.

    Thank you very much and good day!
Please sign in to leave a comment.