Call parallel stages from a loaded file

2022-05-23 Thread chencho m-a
Hi all, 

I have this piece of code

def s
def workspace
pipeline {
  agent { label 'build_1804' }

  stages {
stage('load functions') {
  steps {
script{
  workspace = env.WORKSPACE
  node('build_1804') {
s = load "${workspace}/regress/Jenkins_extension.groovy"   
  }
}
  }
}

stage('Build and Test 1') {
steps{
  script{
s.buildandtest1(this)
  }
}
 }
  }
}

And other file with:
def buildandtest1(Object s) {
  parallel {
echo "Building test"
echo "Calling test script..."
sh """
  cd regress
  echo \"./do_standalone_wo_resnet50_2_58.sh\"
"""
  }
}

}
}

Dont put too much attention in {} or other syntax errors, i have modified 
the code to do it more readable. 

The main problem is that seems that jenkins is not able to start "parallel" 
stages when it is called from a method. I am getting this error. 

java.lang.IllegalArgumentException: Expected named arguments but got 
org.jenkinsci.plugins.workflow.cps.CpsClosure2@6a6de064at 
org.jenkinsci.plugins.workflow.cps.DSL.singleParam(DSL.java:718)at 
org.jenkinsci.plugins.workflow.cps.DSL.parseArgs(DSL.java:706)at 
org.jenkinsci.plugins.workflow.cps.DSL.parseArgs(DSL.java:640)at 
org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:234)


I have googled, but i dont find any solution or clue to fix it.

What am i missing ?

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/66e7b2c8-2090-4770-8c6a-140241c057abn%40googlegroups.com.


Re: Why jenkins doesn't assign jobs to an agent with more resources

2022-03-31 Thread chencho m-a
Inline

El miércoles, 30 de marzo de 2022 a las 23:50:51 UTC+2, nhoj.p...@gmail.com 
escribió:

> Hi,
> Some basic questions;
> - what Jenkins version?
>
2.319.3 (now), but I have been tested several versions 

> - has it ever work for you?
>
No. Even with least-load plugin 

> - you mention 8-9 dockers per agent, is that being controlled using 
> "Number of executors" being set for each agent?
>
I have 1 executor per agent, and I set the amount of dockers running in the 
setup of the plugin (docker-plugin) 

NOTE: I have compiled manually with this proposal PR (not merged due to 
some issues not related with the code)
https://github.com/jenkinsci/leastload-plugin/pull/2

And seems to work fine.



> John
>
>
>
> On Sun, 27 Mar 2022 at 09:30, chencho m-a  wrote:
>
>> Hi all, 
>>
>> I have a cluster with 20 agents, all of them are able to run 8-9 dockers. 
>> In my understanding after installing "least load" plugin, it should take 
>> agent1-docker1 and then, agent2-docker1 but why i am seeing is that it is 
>> using agent1-docker1, agent1-docker2. So I have a node overloaded and 19 
>> more doing nothing. 
>>
>> Any clue?
>>
>> -- 
>> 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/49b2c7f4-139a-4c18-b03d-f2900dcc8717n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/49b2c7f4-139a-4c18-b03d-f2900dcc8717n%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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/c0905a28-8e21-45f7-a50f-7c1e4a9c0dc2n%40googlegroups.com.


Why jenkins doesn't assign jobs to an agent with more resources

2022-03-27 Thread chencho m-a
Hi all, 

I have a cluster with 20 agents, all of them are able to run 8-9 dockers. 
In my understanding after installing "least load" plugin, it should take 
agent1-docker1 and then, agent2-docker1 but why i am seeing is that it is 
using agent1-docker1, agent1-docker2. So I have a node overloaded and 19 
more doing nothing. 

Any clue?

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/49b2c7f4-139a-4c18-b03d-f2900dcc8717n%40googlegroups.com.


Dockers get disconnected when i do git fetch -p

2022-02-08 Thread chencho m-a
Hi all, 

I am facing an issue that is driving me crazy and I am going to ask here to 
see if someone can shed some light.

I have three jenkins clusters with a master per cluster and several 
builders. Each builder is triggering dockers to do certain tasks. I am 
using  jenkins lts and latest docker-plugin (i have tested several plugin 
versions with no luck). The problem is that from time to time I am getting 
this error:

[2022-02-09T00:26:02.052Z] git fetch -p 

[2022-02-09T00:26:08.790Z]
 
Cannot contact build-server-16-quickenv-005qxxrip1351: 
hudson.remoting.ChannelClosedException: Channel 
"hudson.remoting.Channel@58489cec:build-server-16-quickenv-005qxxrip1351": 
Remote call on build-server-16-quickenv-005qxxrip1351 failed. The channel 
is closing down or has closed down 

[2022-02-09T06:54:03.365Z]
 
Could not connect to build-server-16-quickenv-005qxxrip1351 to send 
interrupt signal to process

After this error, docker gets unresponsive from jenkins (but alive in the 
builder with another port, seems like docker socket has dead and 
reconnected in other port), and the jobs never ends waiting for a 
reconnection.

Any idea?

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/cb67e643-9d30-4f4a-bb02-fc88323ace8dn%40googlegroups.com.


Is there a way to trigger a docker container depending on the space on host?

2021-11-20 Thread chencho m-a
Hi, 

I have several jenkins slaves that start dockers containers to build my 
software. I would like to find a way to balance correctly the amount of 
dockers running at the same time. 

Now, this amount is a fixed value and I am wasting resources because I dont 
want to run more than the supported by the host. 

My bottleneck is the HDD, each container takes about 30Gb, and I would like 
to know if there is a plugin that check the hdd in the host, and starts a 
new docker depending on a certain limit .

Regards.

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/d11f89bf-37a6-4694-b83e-db6cad9f3ec9n%40googlegroups.com.


Re: How to throw an error if a parameter is empty?

2020-07-31 Thread chencho m-a

What i want is that when you press the build button, a pop up or error at 
some point appears and stops the execution. 

I think that you need to overload the button in any way, but i dont know 
how to do it.

El viernes, 31 de julio de 2020 a las 15:47:53 UTC+2, 
sinh...@inviarobotics.com escribió:

> You can try executing a basic script that exits 1 if the parameter is not 
> defined (something like -z $parameter) as the first step in the build.  
>
>
>
>  
>
> On July 31, 2020 at 12:33:54 AM, chencho m-a (chen...@gmail.com) wrote:
>
> Hi, 
>
> I have some parameters and i would like to check if they are empty, and if 
> so, dont start the build. 
>
> Any clue?
>
> 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 jenkinsci-use...@googlegroups.com.
>
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-users/1c326abd-4cf2-44f3-9480-f1b9f85bcd70n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-users/1c326abd-4cf2-44f3-9480-f1b9f85bcd70n%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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/2dd05e56-7f5b-4ccc-8270-a94a29ad31a1n%40googlegroups.com.


How to throw an error if a parameter is empty?

2020-07-31 Thread chencho m-a
Hi, 

I have some parameters and i would like to check if they are empty, and if 
so, dont start the build. 

Any clue?

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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/1c326abd-4cf2-44f3-9480-f1b9f85bcd70n%40googlegroups.com.


Issue accesing variable inside script in ActiveChoice plugin (ver2.4)

2020-07-24 Thread chencho m-a
Hi all, 

I have a script which is writting the configuration of ActiveChoice instead 
of use the browser. 

So I am sending a hashmap as parameters but I am unable to acces it inside 
the script 

def components_param(hash_map){ // Section header
return [$class: 'DynamicReferenceParameter',
choiceType: 'ET_FORMATTED_HTML', 
description: '', 
name: '', 
randomName: "choice-parameter-${UUID.randomUUID()}",
omitValueField: false,
referencedParameters: 'sdk',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [], sandbox: false, script: 'return 
["Error,can\'t retrieve components"]',
],
script: [
classpath: [], sandbox: false, script:'''
def output="Components to be updated ${sdk}"
for (comp in  '''+hash_map+'''[sdk].keySet()) {
output += ""+comp+""
}

output+=""
return output
'''
]
]   
]
}

If I check the content in jenkins UI, i got this error:

startup failed:
Script1: 3: illegal colon after argument expression;
   solution: a complex label expression before a colon must be 
parenthesized @ line 3, column 43.

The hash_map in jenkins UI takes this form:

 [devel:[extensions:[extension1:[data:[name:name1, type:generic], 
sdk-ext:sdk-ext-extension1-devel,  extension1-release: 
extension1-sdk-1.21.0.0-devel, ...

How can I parse this hashmap inside ActiveChoice script? In any groovy 
console is something like:

sdks=hash_map.keySet()
sdk=sdks[1]
for (comp in hash_map[sdk].keySet()) {
println comp
}

Any help will be appreciated

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/f8746735-501c-4a9e-91b3-3a423eb3125fn%40googlegroups.com.


Re: Script groovy in Active Choice Parameter

2020-06-17 Thread chencho m-a
Is the file correctly formatted? If you have edited from windows, maybe you 
have wrong line endings

El miércoles, 17 de junio de 2020, 14:38:42 (UTC+2), Antonio Gomez escribió:
>
> Hello,
>
> I am trying to display json file content as multiselect within Choice 
> Active Parameter.
>
> This is my code:
>
> //import groovy.json.JsonSlurperClassic
> import groovy.json.JsonSlurper
>
> //def parseJsonText(String jsonText) {
> //  final slurper = new JsonSlurperClassic()
> //  return slurper.parseText(jsonText)
> // }
>
>
>
> node('master') { 
> 
>
> // def fichero = readFile('/var/jenkins_home/workspace/free/dos.json')
> // configuracion = parseJsonText(fichero)
> //  println configuracion
>
>
>
> def jsonSlurper = new JsonSlurper()
> def object = jsonSlurper.parseText('{ "server": "axn","server2":"azn" }')
> println object 
>
> } 
>
>
> I have tried JsonSlurper and JsonSlurperClassic libraries.
> If the parsing of my json is in text inside the script it works fine, but 
> if I retrieve the json content from a file it doesn't work.
> Both codes are tested as pipelines and return the same result.
>
> Any idea?
>

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/8e65a59a-5be6-4e76-a5d4-b469f38fe77co%40googlegroups.com.


Re: ERROR: exec: /usr/bin/java/bin/java: cannot execute: Not a directory

2020-06-17 Thread chencho m-a
The error says that java is not a directory. Maybe you have your classpath 
pointing to binary instead of the directory

El martes, 16 de junio de 2020, 19:41:01 (UTC+2), Jagadeesh YENNE escribió:
>
> Hi All,
>
>
> While I am running sonar-scanner job, I am getting below error, could someone 
> suggest me how to proceed on it.
>
>
> [MFT-Frontend-CI-Dev-UpdatedNode] $ /bin/bash 
> /tmp/jenkins1683394883835788984.sh
> Running Sonar
>
> > market-forecaster-frontend@0.0.0 sonar 
> > /mnt/block_device/jenkins1/workspace/MFT-Frontend/MFT-Frontend-CI-Dev-UpdatedNode/mft-frontend
> > sonar-scanner
>
> /mnt/block_device/jenkins1/workspace/MFT-Frontend/MFT-Frontend-CI-Dev-UpdatedNode/mft-frontend/node_modules/sonar-scanner/bin/sonar-scanner:
>  line 59: /usr/bin/java/bin/java: Not a directory
> /mnt/block_device/jenkins1/workspace/MFT-Frontend/MFT-Frontend-CI-Dev-UpdatedNode/mft-frontend/node_modules/sonar-scanner/bin/sonar-scanner:
>  line 59: exec: /usr/bin/java/bin/java: cannot execute: Not a directory
> npm ERR! code ELIFECYCLE
> npm ERR! errno 126
> npm ERR! market-forecaster-frontend@0.0.0 sonar: `sonar-scanner`
> npm ERR! Exit status 126
> npm ERR! 
> npm ERR! Failed at the market-forecaster-frontend@0.0.0 sonar script.
> npm ERR! This is probably not a problem with npm. There is likely additional 
> logging output above.
>
> npm ERR! A complete log of this run can be found in:
> npm ERR! 
> /mnt/block_device/jenkins1/.npm/_logs/2020-06-05T18_00_28_687Z-debug.log
> Build step 'Execute shell' marked build as failure
> Finished: FAILURE
>
>
> Regards,
> Jagadeesh
>
>

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/738ac41f-1515-4e1c-9876-f3a662ded949o%40googlegroups.com.


Re: java.io.NotSerializableException: java.lang.UNIXProcess

2020-06-09 Thread chencho m-a
You are right. 

Adding a lot of println debug lines I have realized that the error it was 
not at the piece of code I have posted here but other .execute() which 
whose output was not being consumed and it was blocking the flow.

Thank you all for the tips.

El martes, 9 de junio de 2020, 15:00:26 (UTC+2), Devin Nusbaum escribió:
>
> The method named `exists` from the first email is fine and does not have 
> any problems. Adding @NonCPS to it is incorrect as explained here 
> <https://www.jenkins.io/doc/book/pipeline/cps-method-mismatches/#use-of-pipeline-steps-fromnoncps>
>  and 
> causes the “expected to call Script4.exists but wound up catching sh” 
> warning.
>
> You mentioned using Groovy’s `String.execute()` extension method, which I 
> suspect is the real problem, because that method creates a 
> `java.lang.Process`, which cannot be serialized, and ends up stored as a 
> local variable in the Pipeline, which causes the original error you posted. 
> The Pipeline is serialized after steps execute (when using the default 
> MAX_SURVIVABILITY durability level), which is why you don’t see the error 
> until after the `sh` step runs.
>
> You should not call `String.execute` or other similar Java or Groovy 
> methods related to processes inside of a Pipeline, you should always use 
> the `sh` or `bat` steps. Methods related to `java.lang.Process` will always 
> execute the process on the master (which is probably not the behavior you 
> want), and they are not allowed in the sandbox by default because users can 
> use those methods to trivially bypass all security on the Jenkins master.
>
> On Jun 8, 2020, at 18:57, Slide > wrote:
>
> Can you share your Jenkinsfile? There may be some contextual information 
> that would help people help you.
>
> On Mon, Jun 8, 2020 at 3:08 PM chencho m-a  > wrote:
>
>> I altready tried this, with this output.
>>
>> expected to call Script4.exists but wound up catching sh; see: 
>> https://jenkins.io/redirect/pipeline-cps-method-mismatches/
>>
>> NOTE: if I use execute().text, instead of sh, it works fine.
>>
>>
>>
>>
>> El lunes, 8 de junio de 2020, 19:42:15 (UTC+2), Jérôme Godbout escribió:
>>>
>>> Yet another case of @NonCPS, this serializable requirements for 
>>> functions is such a terrible idea, talk about tentacular requirements that 
>>> destroy standard calls. They should have put recovery point function, where 
>>> the context would have been saved and the script could add them as it 
>>> please, this would have prevent all this @NonCPS nightmare and lead to a 
>>> more standard code with standard groovy.
>>>  
>>>
>>> Add @NonCPS decorator to your functions:
>>>  
>>>
>>> @NonCPS
>>>
>>> def MyFct() {
>>>
>>>… do your stuff here
>>>
>>> }
>>>  
>>>
>>> This prevent serialization of each actions into that functions.
>>>  
>>>
>>> *From:* jenkins...@googlegroups.com  *On 
>>> Behalf Of *chencho m-a
>>> *Sent:* June 8, 2020 5:19 AM
>>> *To:* Jenkins Users 
>>> *Subject:* java.io.NotSerializableException: java.lang.UNIXProcess
>>>  
>>>
>>> Hi all, 
>>>  
>>>
>>> I have a (I hope) stupid issue that i am not able to solve
>>>  
>>>
>>> I am calling to a method that only call a bash script like this.
>>>  
>>>
>>>
>>> def exists(path) {
>>>
>>>try{
>>>
>>>sh(script:'ls -l',
>>>
>>>returnStdout: true).trim()
>>>
>>>return false
>>>
>>>  } catch (err){ error "-E- Failed to run fs.exists(${path}), 
>>> Exception err: ${err}"}
>>>
>>> }
>>>  
>>>
>>>  
>>>
>>> And I am always getting this exception
>>>  
>>>
>>> *07**:**55**:**59*  java.io.NotSerializableException: java.lang.UNIXProcess
>>> [Pipeline] End of Pipeline
>>> an exception which occurred:
>>> in field groovy.lang.Closure.delegate
>>> in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@5ac3f4cc
>>> in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
>>> in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@239d9620
>>> in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@239d9620
>>> Caused: java.io.NotSerializableException: java.lang.UNIXProcess
>>> at 
>

Re: java.io.NotSerializableException: java.lang.UNIXProcess

2020-06-08 Thread chencho m-a
I altready tried this, with this output.

expected to call Script4.exists but wound up catching sh; see: 
https://jenkins.io/redirect/pipeline-cps-method-mismatches/

NOTE: if I use execute().text, instead of sh, it works fine.




El lunes, 8 de junio de 2020, 19:42:15 (UTC+2), Jérôme Godbout escribió:
>
> Yet another case of @NonCPS, this serializable requirements for functions 
> is such a terrible idea, talk about tentacular requirements that destroy 
> standard calls. They should have put recovery point function, where the 
> context would have been saved and the script could add them as it please, 
> this would have prevent all this @NonCPS nightmare and lead to a more 
> standard code with standard groovy.
>
>  
>
> Add @NonCPS decorator to your functions:
>
>  
>
> @NonCPS
>
> def MyFct() {
>
>… do your stuff here
>
> }
>
>  
>
> This prevent serialization of each actions into that functions.
>
>  
>
> *From:* jenkins...@googlegroups.com  <
> jenkins...@googlegroups.com > *On Behalf Of *chencho m-a
> *Sent:* June 8, 2020 5:19 AM
> *To:* Jenkins Users >
> *Subject:* java.io.NotSerializableException: java.lang.UNIXProcess
>
>  
>
> Hi all, 
>
>  
>
> I have a (I hope) stupid issue that i am not able to solve
>
>  
>
> I am calling to a method that only call a bash script like this.
>
>  
>
>
> def exists(path) {
>
>try{
>
>sh(script:'ls -l',
>
>returnStdout: true).trim()
>
>return false
>
>  } catch (err){ error "-E- Failed to run fs.exists(${path}), 
> Exception err: ${err}"}
>
> }
>
>  
>
>  
>
> And I am always getting this exception
>
>  
>
> *07**:**55**:**59*  java.io.NotSerializableException: java.lang.UNIXProcess
> [Pipeline] End of Pipeline
> an exception which occurred:
> in field groovy.lang.Closure.delegate
> in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@5ac3f4cc 
> 
> in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
> in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@239d9620 
> 
> in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@239d9620 
> 
> Caused: java.io.NotSerializableException: java.lang.UNIXProcess
> at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:926)
> at 
> org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
> at 
> org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
> at 
> org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
> at 
> org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
> at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
> at 
> java.util.LinkedHashMap.internalWriteEntries(LinkedHashMap.java:333)
> at java.util.HashMap.writeObject(HashMap.java:1363)
> at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
>
> ...
>
>  
>
>  
>
> Any clue?
>
> Jenkins 2.222.4
>
>  
>
> -- 
> 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 .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-users/1c647bd5-c779-427a-bf98-1a61b5074b65o%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-users/1c647bd5-c779-427a-bf98-1a61b5074b65o%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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/ffbb95d8-8fa2-4401-8a75-5480a10fce1do%40googlegroups.com.


Re: sh vs execute

2020-06-08 Thread 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:* jenkins...@googlegroups.com  <
> jenkins...@googlegroups.com > *On Behalf Of *chencho m-a
> *Sent:* June 8, 2020 9:41 AM
> *To:* Jenkins Users >
> *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 .
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/c7cdb67b-a13d-47b1-8531-dd2b345b6532o%40googlegroups.com.


sh vs execute

2020-06-08 Thread 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 jenkinsci-users+unsubscr...@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.


java.io.NotSerializableException: java.lang.UNIXProcess

2020-06-08 Thread chencho m-a
Hi all, 

I have a (I hope) stupid issue that i am not able to solve

I am calling to a method that only call a bash script like this.


> def exists(path) {
>try{
>sh(script:'ls -l',
>returnStdout: true).trim()
>return false
>  } catch (err){ error "-E- Failed to run fs.exists(${path}), 
> Exception err: ${err}"}
> }
>
>
>
And I am always getting this exception

*07:55:59*  java.io.NotSerializableException: java.lang.UNIXProcess
[Pipeline] End of Pipeline
an exception which occurred:
in field groovy.lang.Closure.delegate
in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@5ac3f4cc
in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@239d9620
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@239d9620
Caused: java.io.NotSerializableException: java.lang.UNIXProcess
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:926)
at 
org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at 
org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
at 
org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
at 
org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
at java.util.LinkedHashMap.internalWriteEntries(LinkedHashMap.java:333)
at java.util.HashMap.writeObject(HashMap.java:1363)
at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)

...


Any clue?

Jenkins 2.222.4

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/1c647bd5-c779-427a-bf98-1a61b5074b65o%40googlegroups.com.