sh vs execute

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

sh vs execute

chencho m-a
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5f27436c-2c6b-4039-abfc-1496d239b981o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

RE: sh vs execute

Jérôme Godbout

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: [hidden email] <[hidden email]> On Behalf Of chencho m-a
Sent: June 8, 2020 9:41 AM
To: Jenkins Users <[hidden email]>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5f27436c-2c6b-4039-abfc-1496d239b981o%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/YQBPR0101MB10741368DDF9440DED63B5C4CD850%40YQBPR0101MB1074.CANPRD01.PROD.OUTLOOK.COM.
Reply | Threaded
Open this post in threaded view
|

Re: sh vs execute

chencho m-a


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: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="21iF7a-ABAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkins...@googlegroups.com <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="21iF7a-ABAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkins...@googlegroups.com> On Behalf Of chencho m-a
Sent: June 8, 2020 9:41 AM
To: Jenkins Users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="21iF7a-ABAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="21iF7a-ABAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkins...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/5f27436c-2c6b-4039-abfc-1496d239b981o%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/5f27436c-2c6b-4039-abfc-1496d239b981o%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/5f27436c-2c6b-4039-abfc-1496d239b981o%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;"> https://groups.google.com/d/msgid/jenkinsci-users/5f27436c-2c6b-4039-abfc-1496d239b981o%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c7cdb67b-a13d-47b1-8531-dd2b345b6532o%40googlegroups.com.