【发布时间】:2014-03-03 16:38:45
【问题描述】:
我希望有人可以提供帮助。我正在尝试为 Jenkins/Hudson 编译一个简单的插件,它将在从属设备上执行代码,但是这段代码无法编译:
// 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),这就是我遇到困难的原因。
感谢您的宝贵时间。
【问题讨论】:
-
您是否以某种方式针对“java.util.concurrent.Callable”而不是“hudson.remoting.Callable”进行编译?
-
嗨尼克,这正是我的问题。我已经切换到现在导入后者,并且一切都正确构建。如果您可以将此添加为答案,那么我可以将其标记为已解决。谢谢!
-
作为答案添加,很高兴它有所帮助。
标签: java maven jenkins hudson jenkins-plugins