当工件不存在时 Jenkins 构建失败
我使用 Jenkins 在 Web 应用程序上运行一些集成测试(使用 cucumber、capybara 和 selenium)
每次测试失败时,都会保存屏幕截图、HTML 源代码和过程视频。
路径结构如下所示:
results/output/<test_name>/<files>
我使用 Jenkins 的归档工件功能来提供文件(模式:results/output/*/*
)。效果很好。
然而,一旦构建成功,就没有屏幕截图/视频等...并且构建失败,因为 Jenkins 找不到该模式的文件。
有没有办法告诉 Jenkins 在没有文件存在的情况下成功?
我不想做一个肮脏的黑客,其中涉及创建一个空文件夹结构,如 result/output/success/hooray.txt。
I use Jenkins to run some integration tests on a web appilcation (using cucumber, capybara and selenium)
Everytime a test fails, a screenshot, the HTML source and a video of the process is saved.
the path structure looks like this:
results/output/<test_name>/<files>
I use the archive artifacts feature of Jenkins to provide the files (pattern: results/output/*/*
). It works great.
However as soon as a build succeeds, there are no screenshots/videos etc... and the build fails because Jenkins cannot find the files for the pattern.
Is there a way to tell Jenkins to succeed without having the files present?
I don't want to do a dirty hack which involves creating an empty folder structure like result/output/success/hooray.txt.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一个悬而未决的问题: https://issues.jenkins-ci.org/browse/JENKINS-10502< /a>
该行为由系统属性
hudson.tasks.ArtifactArchiver.warnOnEmpty
控制,如 https://wiki.jenkins-ci.org/display/JENKINS/Features+driven+通过+系统+属性There's an open issue on for that: https://issues.jenkins-ci.org/browse/JENKINS-10502
The behavior is controlled by the system property
hudson.tasks.ArtifactArchiver.warnOnEmpty
, as explained on https://wiki.jenkins-ci.org/display/JENKINS/Features+controlled+by+system+properties我在我们的几个项目中遇到了类似的问题。我们通过两种不同的方式解决了这个问题(在两个不同的版本上)。
1) 在构建步骤中添加了一个命令,如果不存在任何文件,该命令将创建一个伪造的临时文件。
在本例中,它的目的是收集测试失败时生成的 output.pdf 文件。我添加了一个构建步骤,如果该文件不存在,我们将创建一个“missing.pdf”文件。然后我收集的工件是给定目录中的“*.pdf”。这似乎效果很好。
2) 在另一个版本中,我们需要使用 glob 收集一组文件。
我们在这里所做的就是使构建步骤始终在目标区域中创建一个空文件。这样,glob 总是匹配某些东西。
这些是我们迄今为止找到的最佳解决方案。如果您找到更好的东西,我很想听听。
I ran into a similar issue on a couple of our projects. There are two different ways we have resolved it (on two different builds).
1) Added a command to the build steps that creates a bogus temporary file if no files already existed.
In this case, it was meant to collect an output.pdf file that would be generated if the tests failed. I added a build step where if that file did not exist we created a "missing.pdf" file. Then what I collect as artifacts is '*.pdf' from the given directory. This seems to work out pretty well.
2) On another build we needed to collect a set of files using a glob.
What we did here was made it so the build step always creates a single empty file in the destination area. That way the glob always matches something.
Those are the best solutions we have found so far. If you find something better I would love to hear about it.