Bohdan Sukhov
Bohdan Sukhov

Reputation: 242

Jenkins Job DSL get current build result in postBuildScripts shell

I need to get result of current build execution in postBuildScripts shell call in my Jenkins DSL script. Like ${currentBuild.currentResult} in Jenkins pipelines with values: SUCCESS, UNSTABLE, or FAILURE

I've searched through DSL doc but havent found any solution for that.

My code is something like this:

postBuildScripts {
  steps {
    shell("""echo \$CURRENT_BUILD_STATUS""")
  }
}

So how to get this $CURRENT_BUILD_STATUS in easiest way?

Upvotes: 0

Views: 839

Answers (1)

daspilker
daspilker

Reputation: 8194

Unfortunately the documentation of the PostBuildScript plugin is missing some interesting parts...

job('example') {
  publishers {
    postBuildScripts {
      steps {
        shell('echo $BUILD_RESULT')
      }
    }
  }
}

Upvotes: 1

Related Questions