当詹金斯空闲时自动作业(具有代码覆盖率的phpunit)?
我的 jenkins 安装工作正常,只是我的代码上的 phpunit+coverage 需要 5 分钟才能完成 - 因为太多文件。
对我来说,仅仅知道我的最后一次提交是否破坏了构建就需要等待太多时间。
有没有办法在 jenkins 空闲时运行特殊构建(或计划),并且仅在该构建中它才会创建 phpunit 代码覆盖率报告?
我可以在 cron 中运行 phpunit -c with-coverage.xml ,但它与 jenkins 隔离,它不会刷新 jenkin 的作业主页。
My jenkins install is working properly just that the phpunit+coverage on my code takes 5 minutes finish - because of too many files.
For me, it's too much wait for just knowing if my last commit broke the build or not.
Is there a way I can run a special build (or scheduled) when jenkins is idle and while only in that build it will create phpunit code coverage reports?
I could run phpunit -c with-coverage.xml
in cron but that is isolated from jenkins, it does not refresh jenkin's job home page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个常见的问题:您希望第一层构建能够快速告诉您是否破坏了应用程序,而第二层构建则能够执行更深入的分析。在后一个构建中需要更多时间的事情包括
您可以使用两个单独的 Jenkins 项目来实现这一点——每个项目执行适当的 Ant 任务——其中第二个构建依赖于第一个构建构建的成功。我相信您甚至可以将第一层构建传递工件(例如 junit.xml)到第二层构建,但我还没有时间对此进行试验。
不幸的是,这是一个半答案。我知道你可以做到,但我自己没有做过,也不能一步步告诉你怎么做。希望这能为您提供足够的指导来帮助您入门。
This is a common general problem: you want a first-tier build to quickly tell you if you've broken the application and a second-tier build to perform deeper analysis. Things that take more time in this latter build include
You can achieve this using two separate Jenkins projects--each executing an appropriate Ant task--where the second build is dependent on the first build's success. I believe you can even have the first-tier build pass artifacts (e.g. junit.xml) to the second-tier build, but I haven't had the time to experiment with this yet.
Unfortunately, this is a half-answer. I know you can do it, but I haven't done it myself, nor can I tell you step-by-step how to do it. Hopefully this gives you enough pointers to get you started.
如果您使用 ant 来编排您的构建,也许您甚至不需要两层构建,但您可以使用告诉 Jenkins/Ant 在测试失败时停止,因为您通常并不关心关于破坏构建时的指标。
我倾向于使用的是:
作为第一个构建目标。它将尝试生成代码覆盖率,因此 phpunit 运行需要更长的时间,但您不必花费时间来生成所有指标。
如果你想要非常快:
你可以告诉 Jenkins 有一个“构建后操作”,当你的“运行测试”构建成功时启动另一个构建。您甚至可以将其设置为等待半小时左右来启动“指标”构建,以防万一您进行了 3-4 次提交并且不希望指标构建在第一个完成后立即开始
If you are using
ant
to orchestrate your build maybe you don't even need a two-tier build but you can use tell Jenkins/Ant to stop when your tests fail as you usually don't really care about metrics when you break the build.What I tend to use is:
as on of the first build targets. It will try to generate code-coverage so the phpunit run takes a littler longer but you don't have to spend time to generate all the metrics.
If you want it really fast:
You can tell Jenkins to have a "post build action" that starts another build when your 'run tests' build succeeded. You can even set it up to wait half an hour or so to start the "Metrics" build just in case you do 3-4 commits and don't want the metric build to start immediately after the first one worked out