Q: what stage/branch failed when using failfast with declarative pipelines?

91 views
Skip to first unread message

Victor Martinez

unread,
Aug 14, 2017, 11:48:01 AM8/14/17
to Jenkins Users
Hi there,

Does the currentbuild variable stores where the pipeline failed when using Stages with parallel and failFast = true? For instance:

pipeline {
  agent any
  stages {
    stage('Stage 1') {
      steps {
        parallel(
                 afs_release: { ... },
                 afs_format: { ... },
                 failFast: true
                 )}
    },
    stage('Stage 2') { ... }
  }

  post {
    failure { echo "Failed in the Stage 1 branch afs_format" } // this is hardcoded although I'd like to query this dynamically
  }
}

If the branch "afs_format" failed then I'd like to catch that failure and proceed it at the very end of the post with a customised message.

But as far as I see currentbuild doesn't care about stages/branches but the build itself, 

any hints how I can detect what's the failed stage and within the stage what branch caused that failure?

Thanks



Richard Ginga

unread,
Aug 15, 2017, 9:40:31 AM8/15/17
to jenkins...@googlegroups.com
I do not use declarative pipelines, i use scripted pipelines, but I think you can get the result and some other information from the objects afs_release and afs_format like this:

afs_release.getResult



--
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-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a53685e0-6d39-4fc6-8ed0-463d0a21eb1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Dick Ginga
Build Engineer

Reply all
Reply to author
Forward
0 new messages