构建失败时归档不在工作区中的工件 [英] Archiving artifacts not in the workspace when build fails

查看:34
本文介绍了构建失败时归档不在工作区中的工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的构建中的 ANT 构建步骤失败时,我想存档日志以确定问题.但是,相关日志不在工作区中,因此我必须使用它们的完整路径.

When an ANT build step fails in my build I'd like to archive the logs in order to determine the problem. The relevant logs, however, are not located in the workspace, so I have to use a full path to them.

标准工件归档功能不适用于完整路径,因此首先我必须在某个构建步骤中将日志复制到工作区中,以便我以后可以归档它们.我不想将复制代码合并到原始 ANT 脚本中(它并不真正属于那里).另一方面,由于构建步骤失败,我无法执行将工件复制到工作区的代码作为单独的构建步骤,因为它永远不会到达.

The standard artifact archiving feature does not work well with full paths, so first I have to copy the logs into the workspace within some build step so that I can later archive them. I do not want to incorporate the copying code into the original ANT script (it does not really belong there). On the other hand, since the build step fails the build I can't execute the code that copies the artifacts into the workspace as a separate build step as it is never reached.

我正在考虑使用 ANT -keep-going 选项,但是我将如何使构建失败?

I am considering using ANT -keep-going option, but how will I then fail the build?

任何其他想法(例如,可以优雅地处理完整路径的工件插件)?

Any other ideas (artifact plugins that handle full paths gracefully, for example)?

更新:我通过在工作区中创建一个指向包含要归档文件的目录的符号链接来解决这个问题.笨拙但有效.

Update: I've worked around the problem by creating a symbolic link in the workspace to the directory that contains the files to be archived. Kludgy, but effective.

推荐答案

我建议使用 灵活发布 插件与 Conditional Build步骤插件.

I would recommend using Flexible Publish plugin in conjunction with the Conditional Build Step plugin.

灵活发布插件允许您在构建步骤正常运行后安排构建步骤.这允许您捕获成功和失败的构建并执行某些操作 - 例如将文件从工作区外部复制到工作区内部的脚本.Conditional BuildSet 插件允许对步骤进行条件化,以便它们仅在构建失败时运行.使用这两个插件,您可以在失败时将文件复制到工作区中,然后使用通常的 Jenkins 机制将它们存档.

The Flexible Publish plugin allows you to schedule build steps AFTER the build steps have normally run. This allows you to catch both successful and failed builds and execute something - say a script that copies the files from OUTSIDE the workspace to INSIDE the workspace. The Conditional BuildSet plugin allows conditionalizing the steps so that they only run when the build fails. Using these two plugins, you can copy the files into the workspace upon failure, then archive them with the usual Jenkins mechanisms.

这篇关于构建失败时归档不在工作区中的工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆