在 Hudson 上触发相关作业执行的正确方法
我的工作 A 是在开发人员提交代码(SCM 更改)后构建的。我还有作业 B,应该每天运行一次(通过 cron),并且它应该使用执行构建 A 所产生的工件。
是否可以将 Hudson 作业 B 配置为在 cron 上运行,并且在它真正执行之前应该触发执行作业A?
工作 A 不应该了解工作 B 的任何情况。
I have job A that is building after developers commit code (SCM change). I also have job B that should be run once a day (by cron) and it should use the artifact that results from execution of build A.
Is it possible to configure Hudson job B to run on cron and before it really executes it should trigger execution of job A?
Job A shouldn't know anything about job B.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许是做你想做的事的更好方法。让作业 A 将作业 B 想要的文件标记为工件(在构建之间保留它们)。然后将作业 B 列入其 cron 计划,当它运行时,它使用 Copy Artifact Plugin 从作业 A 检索所需的文件。然后作业 B 可以执行其构建操作。
Perhaps a better way to do what you want. Have Job A mark the files that Job B wants as Artifacts (preserves them between builds). Then have Job B on it's cron schedule and when it runs, it uses the Copy Artifact Plugin to retrieve the required files from Job A. Then Job B can do it's build operation.
如果您有一个 Maven 项目(这也是将工件从一个构建传递到另一个构建的好方法),M2-extra-steps jenkins 插件(我认为现在已弃用并集成到 M2 插件中)允许您执行此操作
:预构建步骤,添加“构建另一个项目”,选中“锁定直到构建完成”,这应该可以满足您的需要。
如果你确实有一个自由式项目 - 我不确定。如果等效的东西不存在,您也许可以想出一些基于锁和闩锁的东西。
话虽如此,如果自上次 SCM 提交以来 A 没有发生变化,为什么要在 B 之前重建 A 呢?
If you have a maven project (which is also a good way to pass artifacts from one build to another), the M2-extra-steps jenkins plugin (now deprecated and integrated into the M2 plugin I think) allows you to do that:
As a pre-build step, add 'build another project', check 'lock until build is done' and that should do what you need.
If you do have a freestyle project - I'm not sure. If the equivalent does not exist you might be able to come up with something based on locks and latches.
All that said, why do you want to rebuild A before B if it hasn't changed since the last SCM commit?