On Fri, Aug 23, 2019 at 3:42 AM Sureshkumar Ramar <
[email protected]> wrote:

> Hi,
> i am using jenkins pipeline. i want to send the failed stage name to the
> developer. is there a way to capture the failure stage in jenkins. it
> should work in parallel stages also.
>

The basic idea is to define a global variable that holds the current stage
name.  At the end of the build, using whatever notification mechanisms you
have available, you send that stage name variable in the notification.

You define a global function called something like "mystage" that looks
something like this:

     def mystage(String stageName, Closure body) {
         env.GLOBAL_STAGE_NAME = stageName
         stage (stageName) {
         try {
             body()
         } catch (err) {
             env.GLOBAL_STAGE_NAME = stageName
             throw err
         }
     }


Then, for each stage in your pipeline, you use this syntax:

    mystage("name of stage") {
        ...
    }

>
> --
> Thanks & Regards,
> Suresh Kumar R
>
> --
> 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/CAM6nqfeQ9sPjgT-nPf%2BhWDY-nuE30%3D3O6No-10WLT3G%2B-jiPvg%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-users/CAM6nqfeQ9sPjgT-nPf%2BhWDY-nuE30%3D3O6No-10WLT3G%2B-jiPvg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAA5t8VoQmXxQjRbnZKC%2BhF0x4NchMcy56jgG894BAqmE1usaOQ%40mail.gmail.com.

Reply via email to