I like to perform in a custom pipeline step some file operations on the 
slave node

The pipeline step calls the method doRemote:

def doRemote() {
    def repoDir = createFilePath("dir_in_repo")
    def callable = new MasterToSlaveFileCallable<Integer>() {

                private static final long serialVersionUID = 1;

                public Integer invoke(File rootDirectory, VirtualChannel 
channel) throws IOException, InterruptedException {
                    def count = 0
                    if(rootDirectory.exists()) {
                        // TODO
                    }
                    return 0
                }
            };
    def count = repoDir.act(callable);
}

def createFilePath(path) {
    if (env['NODE_NAME'] == null) {
        error "envvar NODE_NAME is not set, probably not inside an node {} 
or running an older version of Jenkins!";
    } else if (env['NODE_NAME'].equals("master")) {
        return new FilePath(path);
    } else {
        return new FilePath(Jenkins.getInstance().getComputer(env[
'NODE_NAME']).getChannel(), path);
    }
}



Whenever the step is executed it fails with the following exception:

[Bitbucket] Build result notified
java.lang.IllegalArgumentException: Unable to locate class file for class 
customStep$1
        at hudson.remoting.Which.classFileUrl(Which.java:61)
        at 
hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch4(RemoteClassLoader.java:847)
        at 
hudson.remoting.RemoteClassLoader$ClassLoaderProxy.fetch3(RemoteClassLoader.java:875)


I moved already the anonymous class into a separate file. It did also not 
work.

Is it not possible to use the FilePath.act method in a custom pipeline step?

  Richard


-- 
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/2d10cb45-5d06-43d5-8c98-ed09f556eb48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to