我希望有人可以提供帮助。我正在尝试为Jenkins / Hudson编译一个简单的插件,它将在slave上执行代码,但是这段代码无法编译:
// 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);
在声明Callable变量Task时尝试编译时遇到异常。错误是'错误:类型参数的数量错误;需要1'。
我是创建jenkins插件和Java的新手,所以我希望有经验的人可以帮助我。我已经广泛搜索过,文档显示我正在做正确的事情(http://grepcode.com/file/repo1.maven.org/maven2/org.jvnet.hudson.main/remoting/1.366/hudson/remoting/Callable.java#Callable),这就是我陷入困境的原因。
感谢您的时间。
答案 0 :(得分:0)
您正在查看Jenkins代码的旧版本。以下是current JavaDo c和latest cod e的链接。
看起来您尝试使用的Remoting类不再存在。
答案 1 :(得分:0)
你是在编译'java.util.concurrent.Callable'而不是'hudson.remoting.Callable'吗?检查import语句。