2014-03-03 43 views
0

我希望有人可以提供帮助。我试图编译詹金斯/哈德森一个简单的插件,将在从执行代码,但是这个代码块未能编译:试图声明时,编译时使用Java和Maven编译Jenkins插件时出错

// 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); 

我发现了一个异常可调用变量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

你是否以某种方式编译'java.util.concurrent.Callable'而不是'hudson.remoting.Callable'? –

+0

嗨,尼克,这正是我的问题。我已经切换到导入后者,并且它的所有内容都正确构建。如果你可以添加这个答案,那么我可以将其标记为已解决。谢谢! – ChrisD88

+0

作为回答添加,很高兴帮助。 –

回答

0

您是否针对'java.util.concurrent.Callable'而不是'hudson.remoting.Callable'进行编译?检查导入语句。

0

您正在查看Jenkins代码的真正旧版本。这里有链接current JavaDo c和latest cod e。

它看起来好像您尝试使用的Remoting类不再存在。

+0

嗨加雷思,虽然这不是问题(请参阅上面的Nick的评论),但有这些链接并且看一看,非常方便,所以谢谢。 – ChrisD88

相关问题