Tried the following that got rid of "Unable to serialize", but still does
not work. Most of the examples I find online for FilePath.act does not work
in Script Console.
import hudson.FilePath.FileCallable
import hudson.remoting.VirtualChannel
import org.jenkinsci.remoting.RoleChecker
def jenkinsInstance = jenkins.model.Jenkins.getInstance()
def project = jenkinsInstance.getItem("myMatrixProject")
def rootProject = project.getRootProject()
def someWorkspace = rootProject.getSomeWorkspace()
private class MyFileCallable implements FileCallable<String> {
private static final long serialVersionUID = 1L;
@Override
public String invoke(File file, VirtualChannel channel) throws
IOException, InterruptedException {
return "Testing Testing";
}
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
}
}
try {
def test = someWorkspace.act(new MyFileCallable());
println test
} catch (IOException e) {
println e.getMessage()
} catch (InterruptedException e) {
println e.getMessage()
}
remote file operation failed: /home/build/jenkins/workspace/myMatrixProject at
hudson.remoting.Channel@54e95cec:Development-opensuse-x86_64:
java.io.IOException: Remote call on Development-opensuse-x86_64 failed
onsdag 25. mars 2015 10.03.35 UTC+1 skrev Sverre Moe følgende:
>
> I have added checkRoles within my FileCallable implementation, but it
> still fails. Though this time with a different message.
>
> remote file operation failed: /home/build/jenkins/workspace/myMatrixProject
> at hudson.remoting.Channel@54e95cec:Development-opensuse-x86_64:
> java.io.IOException: Unable to serialize
> hudson.FilePath$FileCallableWrapper@5a17f7bd
>
>
> import hudson.FilePath.FileCallable
> import hudson.remoting.VirtualChannel
> import org.jenkinsci.remoting.RoleChecker
>
> def jenkinsInstance = jenkins.model.Jenkins.getInstance()
> def project = jenkinsInstance.getItem("myMatrixProject")
> def rootProject = project.getRootProject()
> def someWorkspace = rootProject.getSomeWorkspace()
>
> try {
> def test = someWorkspace.act(new FileCallable<String>() {
> private static final long serialVersionUID = 1;
> @Override
> public String invoke(File file, VirtualChannel channel) {
> return "Testing Testing";
> }
>
> @Override
> public void checkRoles(RoleChecker checker) throws
> SecurityException {
>
> }
> });
>
> println test
> } catch (IOException e) {
> println e.getMessage()
> } catch (InterruptedException e) {
> println e.getMessage()
> }
>
>
> Could you ellaborate on "use the provided abstract base classes as
> parent" ?
>
>
> tirsdag 24. mars 2015 18.29.12 UTC+1 skrev Ullrich Hafner følgende:
>>
>> You need to implement the new method checkRoles. See JavaDoc of latest
>> FileCallable
>> version. (Or you can use the provided abstract base classes as parent).
>>
>> Am 24.03.2015 um 18:03 schrieb Sverre Moe <[email protected]>:
>>
>>
>> Trying the following in Jenkins Script Console:
>>
>> import hudson.FilePath.FileCallable
>> import hudson.remoting.VirtualChannel
>>
>> def jenkinsInstance = jenkins.model.Jenkins.getInstance()
>> def project = jenkinsInstance.getItem("myMatrixProject")
>> def rootProject = project.getRootProject()
>> def someWorkspace = rootProject.getSomeWorkspace()
>>
>> try {
>> def test = someWorkspace.act(new FileCallable<String>() {
>> private static final long serialVersionUID = 1;
>> @Override
>> public String invoke(File file, VirtualChannel channel) {
>> return "Testing Testing";
>> }
>> });
>> } catch (IOException e) {
>> e.printStackTrace();
>> } catch (InterruptedException e) {
>> e.printStackTrace();
>> }
>>
>> It throws an exception:
>>
>> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
>> failed:
>> Script1.groovy: 10: Can't have an abstract method in a non-abstract class.
>> The class 'Script1$1' must be declared abstract or the method 'void
>> checkRoles(org.jenkinsci.remoting.RoleChecker)' must be implemented.
>> @ line 10, column 61.
>> ct(new FileCallable<String>() {
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Jenkins Developers" 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-dev/b2502c2c-8a02-46df-8bce-90ee10724090%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/jenkinsci-dev/b2502c2c-8a02-46df-8bce-90ee10724090%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" 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-dev/542700b1-0571-4bf8-b6bc-b845c72df431%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.