sh vs execute

40 views
Skip to first unread message

chencho m-a

unread,
Jun 8, 2020, 1:29:56 PM6/8/20
to Jenkins Users
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.

Jérôme Godbout

unread,
Jun 8, 2020, 1:38:15 PM6/8/20
to jenkins...@googlegroups.com

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.

--
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/5f27436c-2c6b-4039-abfc-1496d239b981o%40googlegroups.com.

chencho m-a

unread,
Jun 8, 2020, 2:05:50 PM6/8/20
to Jenkins Users


El lunes, 8 de junio de 2020, 19:38:15 (UTC+2), Jérôme Godbout escribió:

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.


I have discovered it is an issue with ScriptSecurity plugin and ActiveChoices. I have upgraded my jenkins but it is still happening.

I dont know why it is still giving me the exception. If i run the same piece of code outside my pipeline, it works... 


 

 

From: jenkins...@googlegroups.com <jenkins...@googlegroups.com> On Behalf Of chencho m-a
Sent: June 8, 2020 9:41 AM
To: Jenkins Users <jenkins...@googlegroups.com>
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 jenkins...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages