down votefavorite
<https://stackoverflow.com/questions/45924945/scoping-of-a-groovy-variable-inside-a-closure-in-try-to-access-from-catch#>
how do i access the value of a variable assigned inside a closure within a
try() in the catch() statement. here is what i am trying to achieve but i
keep getting the initialization value that i assigned.
node('linux') {
def val_log = null;
try{
stage('abc') {
val_log = //some steps that generates a log that i want
}
println '$val_log' //this works
}
catch(err)
stage('mail') {
// code to send email notification with '$val_log'
//--> the $val_log returns 'null' and not the
//value assigned in the try() part.
}}
Is there a way, to get the value for the variable inside the catch()
statement.
Thank you...
--
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/CAPzcO4iK8F4vJ_D-0n2Gpnxph99Km9RCFQ52jtj9OqKY-E7K-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.