No, the annotation wouldn't help with this, I believe.
The problem is, when "job steps" execute, objects are deserialized
before and after. If Jenkins has to try to serialize something in
scope that is not serializable, you will get that exception. What is
often very frustrating is that the stacktrace won't tell you which
variable contains something that is not serializable. What it will
usually tell you is what type was not serializable. If you're lucky,
it will be obvious what variable has a value of that type. In your
case, I believe is it obvious.
The other thing that is not obvious is that "println" is a job step.
If you really need to do a println, then right before you call it, you
have to assign "null" to variables containing values of
non-serializable types.
In your "getjobName" method, it's odd that your formal parameter is
called "job", when it's really "jobName", and then you appear to
assign to "jobname", which isn't defined anywhere, but the value
actually represents a "Job", not a "jobname".
>
>
> /Ram
>
> --
> 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-use...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/jenkinsci-users/68199c67-9ccf-42e2-8bf3-f38fe4708350%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.