Question

I'm hoping somebody could help. I'm trying to compile a simple plugin for Jenkins/Hudson that will execute code on a slave, however this block of code is failing to compile:

// Define what should be run on the slave for this build
Callable<String, IOException> task = new Callable<String, IOException>() {
    public String call() throws IOException {
        // This code will run on the build slave
        return InetAddress.getLocalHost().getHostName();
    }
};
// Get a "channel" to the build machine and run the task there
String hostname = launcher.getChannel().call(task);

I'm getting an exception when trying to compile when declaring the Callable variable Task. The error is 'error: wrong number of type arguments; required 1'.

I'm new to both creating jenkins plugins and Java so I'm hoping someone more experienced could aid me. I've googled extensively and the documentation suggests I'm doing the right thing (http://grepcode.com/file/repo1.maven.org/maven2/org.jvnet.hudson.main/remoting/1.366/hudson/remoting/Callable.java#Callable) which is why I've came up stuck.

Thanks for your time.

Était-ce utile?

La solution

Are you compiling against 'java.util.concurrent.Callable' rather than 'hudson.remoting.Callable'? Check the import statements.

Autres conseils

You're looking at a really old version of the Jenkins code. Here are links to the current JavaDoc and the latest code.

It looks as if the Remoting class that you were trying to use doesn't exist any more.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top