Hudson Slave 可以运行插件吗?
我们有一个 Hudson 的自定义插件,它将构建的输出上传到远程计算机上。我们刚刚开始研究使用 Hudson 从站来提高构建的吞吐量,但是使用自定义插件的项目无法部署并出现 FileNotFoundExceptions。
从我们所看到的来看,即使构建是在从机上进行的,插件也在主机上运行。未找到的文件确实存在于从属服务器上,但不存在于主服务器上。
问题:
- 插件可以在从属设备上运行吗?如果是这样,怎么办?有没有办法将插件识别为“可序列化”?如果 Hudson 从机无法运行插件,那么 SVN 签出是如何发生的?
- 这里的一些开发人员认为解决这个问题的方法是将 Hudson 主设备的工作空间设置为网络驱动器,并让从设备使用相同的工作空间 - 这在我看来是一个糟糕的想法吗?
We have a custom plugin for Hudson which uploads the output of a build onto a remote machine. We have just started looking into using a Hudson slave to improve throughput of builds, but the projects which use the custom plugin are failing to deploy with FileNotFoundExceptions.
From what we can see, the plugin is being run on the master even when the build is happening on the slave. The file that is not being found does exist on the slave but not on the master.
Questions:
- Can plugins be run on slaves? If so, how? Is there a way to identify a plugin as being 'serializable'? If Hudson slaves can't run plugins, how does the SVN checkout happen?
- Some of the developers here think that the solution to this problem is to make the Hudson master's workspace a network drive and let the slave use that same workspace - is this as bad an idea as it seems to me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,使用 Jenkins! ;)
其次,你是对的——代码正在主服务器上执行。这是 Hudson/Jenkins 插件的默认行为。
当您想要在远程节点上运行代码时,您需要获取对该节点的
VirtualChannel
,例如通过Launcher
可能会传递到插件的 main 方法中。要在远程节点上运行的代码应封装在
Callable
— 这是需要可序列化的部分,因为 Jenkins 会自动序列化它,通过其通道将其传递到节点,执行它并返回结果。这也隐藏了主设备和从设备之间的区别——即使构建实际上在主设备上运行,“可调用”代码也将透明地在正确的机器上运行。
例如:
另请参阅
FileCallable
,并查看源代码具有类似功能的其他 Jenkins 插件。我建议让您的插件正常工作,而不是使用网络共享解决方案..:)
Firstly, go Jenkins! ;)
Secondly, you are correct — the code is being executed on the master. This is the default behaviour of a Hudson/Jenkins plugin.
When you want to run code on a remote node, you need to get a reference to that node's
VirtualChannel
, e.g. via theLauncher
that's probably passed into your plugin's main method.The code to be run on the remote node should be encapsulated in a
Callable
— this is the part that needs to be serialisable, as Jenkins will automagically serialise it, pass it to the node via its channel, execute it and return the result.This also hides the distinction between master and slave — even if the build is actually running on the master, the "callable" code will transparently run on the correct machine.
For example:
See also
FileCallable
, and check out the source code of other Jenkins plugins with similar functionality.I would recommend making your plugin work properly rather than using the network share solution.. :)