Re: EnvInject - groovy script in Jenkins 2.x

2017-02-11 Thread Giulio Pulina
Hi, 

did you manage to solve this issue? I'm stuck with a similar setup and 
similar error.. 

Thanks in advance
Giulio

Il giorno giovedì 28 luglio 2016 23:43:16 UTC+2, Simona Avornicesei ha 
scritto:
>
> A new update. I fixed the "The class 'FileSearch' has an incorrect 
> modifier static." - the static class must be embedded in  another class. 
> Here's 
> the gist 
> .
>
> Now I'm left with 2 other issues:
> 1. at build time (isDebugMode = false)  Thread.currentThread()?.executable 
> returns null. Always. I think it's something related to the job running on 
> the slave but I have no idea with what should I replace it to make it work.
> 2. if the script is run (from job or from Scriptler) with isDebugMode = 
> true, the remote communication fails with:
>
> FATAL: remote file operation failed: 
> d:\jenkins\workspace\My_Project_Name/Src/SolutionInfo.cs at 
> hudson.remoting.Channel@1b37fe1:win_01: java.io.IOException: Remote call on 
> win_01 failedjava.io.IOException 
> : remote 
> file operation failed: 
> d:\jenkins\workspace\My_Project_Name/Src/SolutionInfo.cs at 
> hudson.remoting.Channel@1b37fe1:win_01: java.io.IOException: Remote call on 
> win_01 failed
>   at hudson.FilePath.act(FilePath.java:1014) 
> 
>   at hudson.FilePath.act(FilePath.java:996) 
> 
>   at hudson.FilePath$act$1.call(Unknown Source)
> [...]
>
> java.io.IOException: Remote call on win_01 failed
>
> [...]
>
> java.lang.Error: Failed to deserialize the Callable object.
>
> [...]
>
> java.lang.IllegalArgumentException: Unable to locate class file for class 
> FileParser$FileSearch
>   at hudson.remoting.Which.classFileUrl(Which.java:60)
>   at 
> hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch4(RemoteClassLoader.java:775)
>   at 
> hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch3(RemoteClassLoader.java:803)
>   at sun.reflect.GeneratedMethodAccessor2256.invoke(Unknown Source)
>   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>   at java.lang.reflect.Method.invoke(Unknown Source)
>   at 
> hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:884)
>   at hudson.remoting.Request$2.run(Request.java:332)
>
>
> I updated the slave.jar used on the slave machine and restarted the agent. 
> Both master and slave machines have Win 7 on them and are configured the 
> same (jenkins path, java version, etc).
> I also cannot replace the groovy script with something else because it's 
> evaluated by EnvInject.
>

-- 
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/f29c837f-aec3-4ff3-8ff4-6dfd51166f42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: EnvInject - groovy script in Jenkins 2.x

2016-07-28 Thread Simona Avornicesei
A new update. I fixed the "The class 'FileSearch' has an incorrect modifier 
static." - the static class must be embedded in  another class. Here's the 
gist 
.

Now I'm left with 2 other issues:
1. at build time (isDebugMode = false)  Thread.currentThread()?.executable 
returns null. Always. I think it's something related to the job running on 
the slave but I have no idea with what should I replace it to make it work.
2. if the script is run (from job or from Scriptler) with isDebugMode = 
true, the remote communication fails with:

FATAL: remote file operation failed: 
d:\jenkins\workspace\My_Project_Name/Src/SolutionInfo.cs at 
hudson.remoting.Channel@1b37fe1:win_01: java.io.IOException: Remote call on 
win_01 failedjava.io.IOException 
: remote 
file operation failed: d:\jenkins\workspace\My_Project_Name/Src/SolutionInfo.cs 
at hudson.remoting.Channel@1b37fe1:win_01: java.io.IOException: Remote call on 
win_01 failed
at hudson.FilePath.act(FilePath.java:1014) 

at hudson.FilePath.act(FilePath.java:996) 

at hudson.FilePath$act$1.call(Unknown Source)
[...]

java.io.IOException: Remote call on win_01 failed

[...]

java.lang.Error: Failed to deserialize the Callable object.

[...]

java.lang.IllegalArgumentException: Unable to locate class file for class 
FileParser$FileSearch
at hudson.remoting.Which.classFileUrl(Which.java:60)
at 
hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch4(RemoteClassLoader.java:775)
at 
hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch3(RemoteClassLoader.java:803)
at sun.reflect.GeneratedMethodAccessor2256.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at 
hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:884)
at hudson.remoting.Request$2.run(Request.java:332)


I updated the slave.jar used on the slave machine and restarted the agent. 
Both master and slave machines have Win 7 on them and are configured the 
same (jenkins path, java version, etc).
I also cannot replace the groovy script with something else because it's 
evaluated by EnvInject.

-- 
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/eaed7132-699d-40e1-9434-352599cccddc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: EnvInject - groovy script in Jenkins 2.x

2016-07-28 Thread Simona Avornicesei
Hello,

I modified the script to use FilePath (since the job runs on a remote agent 
and, from my understanding, the groovy script is executed on master) - here 
's 
the updated gist 

When run from Scriptler, I get the following error:
[(master)]:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
failed:
Script1.groovy: 38: The class 'FileSearch' has an incorrect modifier static.
 @ line 38, column 1.
   private static class FileSearch implements FileCallable {
   ^

Script1.groovy: 38: The class 'FileSearch' has an incorrect modifier 
private.
 @ line 38, column 1.
   private static class FileSearch implements FileCallable {
   ^

2 errors

at 
org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
at 
org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1073)
at 
org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591)
at 
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569)
at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546)
at 
groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
at groovy.lang.GroovyShell.parse(GroovyShell.java:736)
at groovy.lang.GroovyShell.parse(GroovyShell.java:727)
at 
org.jenkinsci.plugins.scriptler.util.GroovyScript.call(GroovyScript.java:117)
at hudson.remoting.LocalChannel.call(LocalChannel.java:45)
at 
org.jenkinsci.plugins.scriptler.util.ScriptHelper.runScript(ScriptHelper.java:124)

-- 
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/b4a0e6b3-3c3c-4a78-8cb9-f9dad1d733fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: EnvInject - groovy script in Jenkins 2.x

2016-07-25 Thread Daniel Beck

> On 22.07.2016, at 11:47, Simona Avornicesei  wrote:
> 
> As a side question, I noticed lots of methods and classes are deprecated from 
> Hudson.* packages. As a best practice, should I use only the jenkins.* 
> packages in the groovy scripts?

Deprecation is generally unrelated to the package. It's just that hudson.* 
classes are typically older, i.e. greater chance of deprecation due to 
continued development.

-- 
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/145EB69C-C524-410C-84AB-940DC882EDDC%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.


EnvInject - groovy script in Jenkins 2.x

2016-07-22 Thread Simona Avornicesei
Hello,

I have an old groovy script that I've been using to inject some env. 
variables into the job. It run nicely under Jenkins 1.x, on the master 
Jenkins instance.
Now we've moved to a Jenkins cluster and Jenkins 2.x and the script fails 
to get a valid workspace for the current build (the job always executes on 
the same Windows slave).

This is the error:
- when isDebugMode = false

FATAL: Current build workspace is null! java.lang.Exception 
: Current 
build workspace is null!

- when isDebugMode = true and I run the script in the Scriptler console
java.lang.NullPointerException: Cannot invoke method getLastSuccessfulBuild() 
on null object


This is the script: 
https://gist.github.com/savornicesei/c9dbafec8339b1e8d18c1d4a6e620baa

As a side question, I noticed lots of methods and classes are deprecated 
from Hudson.* packages. As a best practice, should I use only the jenkins.* 
packages in the groovy scripts?

Thanks.

-- 
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/5422d876-ca13-49ef-b542-407f98d28439%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.