Sounds like you need to put the function where the sh is called into a @NonCPS 
decorator on that function.

@NonCPS
def MyFct() {
  sh(“ls”);
}

That should remove the need for serialization of that command ainto this 
function.

From: [email protected] <[email protected]> On 
Behalf Of chencho m-a
Sent: June 8, 2020 9:41 AM
To: Jenkins Users <[email protected]>
Subject: sh vs execute

Hi all,

I am suffering a weird issue with sh when i am calling a simple ls from a 
groovy script inside jenkins, but if I use execute().text, it works fine.

Why does sh return java.lang.UNIXProcess an throw NonSerializableException and 
execute() works fine?

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]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/5f27436c-2c6b-4039-abfc-1496d239b981o%40googlegroups.com<https://groups.google.com/d/msgid/jenkinsci-users/5f27436c-2c6b-4039-abfc-1496d239b981o%40googlegroups.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/YQBPR0101MB10741368DDF9440DED63B5C4CD850%40YQBPR0101MB1074.CANPRD01.PROD.OUTLOOK.COM.

Reply via email to