在 Jenkins 中归档工件

发布于 2024-11-03 18:12:35 字数 524 浏览 0 评论 0原文

有人可以向我解释构建过程中工件的想法吗?

我有工作区目录,我可以在其中检查代码以编译和运行我的 ant 脚本等。最后,就我而言,我得到一个可以安装的 jar 文件。这算是神器吗?

我应该告诉我的构建脚本将 jar 文件放在哪里?在工作区目录中?我的 jar 文件根据 BUILD_ID 等变量获得唯一的文件名,我如何告诉 Jenkins 选择哪个 jar 文件?

编辑: 好的,所以我尝试做这样的事情:

在此处输入图像描述

该路径在我的工作区中尚不存在,因为构建脚本应该创建它,当然,.jar.properties 文件不存在,因为它们尚未生成。那为什么它会给我一个错误?好像我错过了一些东西。

另外,Jenkins 是否会在每次构建后删除工件(不是存档的工件,我知道我可以告诉它删除这些工件)?否则它会很快堵塞硬盘。

Could someone please explain to me the idea of artifacts in the build process?

I have the workspace directory where I check out the code to compile and run my ant scripts etc. At the end, in my case, I get a jar file that's ready to install. Is that considered to be the artifact?

Where should I tell my build script to put the jar file? In the workspace directory? My jar file gets a unique filename depending on variables like BUILD_ID and such, how can I tell Jenkins which jar file to pick?

EDIT:
Okay, so i tried doing something like this:

enter image description here

The path does not exist yet in my workspace, because the build script is supposed to create it, and of course, the .jar and .properties files are not there because they haven't been generated yet. Why does it give me an error then? Seems like I'm missing something.

Also, does Jenkins delete the artifacts after each build (not the archived artifacts, I know I can tell it to delete those)? Otherwise it will clog the hard drive pretty quickly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

此生挚爱伱 2024-11-10 18:12:35

您的理解是正确的,Jenkins 意义上的工件是构建的结果 - 构建过程的预期输出。

常见的约定是将构建结果放入 buildtargetbin 目录中。

Jenkins 存档器可以使用 glob (target/*.jar) 轻松获取正确的文件,即使每个构建都有唯一的名称。

Your understanding is correct, an artifact in the Jenkins sense is the result of a build - the intended output of the build process.

A common convention is to put the result of a build into a build, target or bin directory.

The Jenkins archiver can use globs (target/*.jar) to easily pick up the right file even if you have a unique name per build.

断桥再见 2024-11-10 18:12:35

工件可以是构建过程的任何结果。重要的是,无论它是在哪个客户端上构建的,它都会从工作区传输回主服务器(服务器)并存储在那里并带有指向构建的链接。优点是它以这种方式进行版本化,您只需在主服务器上设置备份,并且即使所有构建客户端都处于离线状态,也可以通过 Web 界面访问所有工件。

可以将正则表达式定义为工件名称。就我而言,我在构建过程中将想要存储的所有文件压缩到一个具有常量名称的文件中。

An artifact can be any result of your build process. The important thing is that it doesn't matter on which client it was built it will be tranfered from the workspace back to the master (server) and stored there with a link to the build. The advantage is that it is versionized this way, you only have to setup backup on your master and that all artifacts are accesible via the web interface even if all build clients are offline.

It is possible to define a regular expression as the artifact name. In my case I zipped all the files I wanted to store in one file with a constant name during the build.

呆萌少年 2024-11-10 18:12:35

此外,Jenkins 会在每次构建后删除工件吗? (不是存档的工件,我知道我可以告诉它删除那些)

不,Hudson/Jenkins 本身不会在构建后清除工作区。您可能在构建过程中执行一些操作,这些操作会擦除、覆盖或移动构建工件。作业配置中的“高级项目选项”(必须展开)中有一个选项,称为“构建之前清理工作空间”,它将在新构建开始时擦除工作空间。

Also, does Jenkins delete the artifacts after each build ? (not the archived artifacts, I know I can tell it to delete those)

No, Hudson/Jenkins does not, by itself, clear the workspace after a build. You might have actions in your build process that erase, overwrite, or move build artifacts from where you left them. There is an option in the job configuration, in Advanced Project Options (which must be expanded), called "Clean workspace before build" that will wipe the workspace at the beginning of a new build.

橘寄 2024-11-10 18:12:35

在 Jenkins 2.60.3 中,有一种方法可以删除构建工件(不是存档的工件),以节省构建机器上的硬盘空间。在“常规”部分中,使用“日志轮换”策略选中“放弃旧版本”,然后进入其“高级”选项。将出现另外两个选项,与根据天数或构建数量保留作业的构建工件相关。

对我有用的设置是在“与工件保持的最大构建数”中输入 1,然后进行构建后操作来存档工件。这样,所有构建中的所有工件都将被存档,构建中的所有信息都将被保存,但只有最后一个构建才会保留自己的工件。

放弃旧的构建选项

In Jenkins 2.60.3 there is a way to delete build artifacts (not the archived artifacts) in order to save hard drive space on the build machine. In the General section, check "Discard old builds" with strategy "Log Rotation" and then go into its Advanced options. Two more options will appear related to keeping build artifacts for the job based on number of days or builds.

The settings that work for me are to enter 1 for "Max # of builds to keep with artifacts" and then to have a post-build action to archive the artifacts. This way, all artifacts from all builds will be archived, all information from builds will be saved, but only the last build will keep its own artifacts.

Discard old builds options

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文