Jenkins - 在另一项工作中使用一项工作的结果

发布于 2024-12-07 01:08:23 字数 86 浏览 0 评论 0原文

我有一份运行 makefile 并生成一些文件的工作。然后我想要另一份工作将这些文件发布到 ivy。

我知道克隆工作区插件,但还有其他选择吗?

I have a job that runs a makefile and generates some files. I then want another job that publishes these files to ivy.

I am aware of the clone workspace plugin, but is there any other options?

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

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

发布评论

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

评论(5

葵雨 2024-12-14 01:08:23

您运行Makefile,然后发布到Ivy

Ivy 是 Ant 的一部分,是一个利用全球 Maven 存储库结构来获取所需 jar 文件和其他依赖项的模块。

不要误会我的意思,我使用本地远程 Maven 存储库来发布其他项目将依赖的 C/C++ 库(您可以使用 wget 来获取项目)。但是,我没有使用 Ivy 来做到这一点。

如果您正在考虑 Apache Ivy,那么您可以使用 Maven 进行发布。有一个 Maven Release 插件可以将您的工件复制到您的 Maven 存储库,但您可能想要做的是部署。

在我的 Jenkins 构建中,我只是让 Jenkins 从命令行执行 maven 的 deploy-file 步骤。这允许我将文件部署到我的 Maven Ivy 存储库中,而无需先创建 pom.xml 文件。 (嗯,无论如何你都想创建一个 pom.xml,因为你想包含一个依赖层次结构。)

我通常在创建 jar/war/ear 文件的同一工作中执行此操作。但是,如果您想要单独的工作来执行此操作,可以使用 Copy神器插件。该插件允许作业 B 复制作业 A 中的任何或所有已发布的工件。如果您只需要构建的 jar 文件,这比克隆整个工作区更快、更简单。

You run a Makefile, and you're publishing to Ivy?

Ivy is part of Ant, and is a module that takes advantage of the worldwide Maven repository structure to grab required jarfiles and other dependencies.

Don't get me wrong, I've used a local remote Maven repository to publish C/C++ libraries (you can use wget to fetch the items) that other projects will depend upon. But, I didn't do that using Ivy.

If you're thinking of Apache Ivy, then you can publish using Maven. There's a Maven Release plugin that will copy your artifact to your Maven repository, but what you probably want to do is deploy.

In my Jenkins builds, I simply had Jenkins execute maven's deploy-file step from the command line. This allowed me to deploy files into my Maven Ivy repository without having to first create a pom.xml file. (Well, you want to create a pom.xml anyway because you want to include a dependency hierarchy.)

I usually did this in the same job as the job that created my jar/war/ear file. However, if you want a separate job to do this, you can use the Copy Artifact Plugin. This plugin allows Job B to copy any or all of the published artifacts from Job A. That's a lot faster and simpler than cloning a whole workspace if you just want the built jar files.

小霸王臭丫头 2024-12-14 01:08:23

我个人的偏好是在不依赖 Jenkins 内部文件结构的情况下完成这些事情,尽管有时这意味着了解其他构建工具(例如 Maven,或者在您的情况下为 Ivy)的内部结构。

如果我是你,我会在一项工作中完成所有工作 - 即构建,然后让“Ivy Publisher”(如果存在这样的插件)将工件发布到远程 Ivy 存储库。

如果这是不可能的,请让第一个作业将工件“安装”到本地存储库/缓存中(我不确定它在 Ivy 上的名称),然后让第二个作业从那里获取它。

我不确定这一定是最好的方法,但它对我来说效果很好。

编辑 我应该提到 - 这在分布式环境中效果不太好,除非像我一样,您的分布式环境由多个可以访问通用 NAS 文件系统的节点组成。

编辑2我还使用了 Copy用于没有通用文件系统的分布式环境的从属插件

My personal preference is to do these sort of things without relying on the Jenkins internal file structure, though sometimes this mean knowing about the internal structure of your other build tools (e.g., Maven, or in your case Ivy).

If I were you, I'd do everything in one job - i.e., build, and then have an "Ivy Publisher" (if such a plug in exists) publish the artifact to the remote Ivy repository.

If that's not possible, have the first job "install" the artifact into the local repository/cache (I'm not sure what it's called on Ivy), and then have the second job pick it up from there.

I'm not sure this is necessarily the best approach, but it has worked well for me.

Edit I should mention - this doesn't work so well on distributed environments, unless like me, your distributed environment consists of multiple nodes that have access to a common NAS filesystem.

Edit 2 I have also used the Copy To Slave Plugin for distributed environments without a common filesystem.

蝶舞 2024-12-14 01:08:23

您有多种选择,其中之一是克隆工作区,它工作得相当好,但所需的磁盘空间增加了一倍(在我们的例子中这是非常相关的)。大多数其他方式都是克隆工作区的变体。

我所做的是使用自定义工作区位置。即我的第一份工作构建了一切,然后触发了第二份工作。在第二个作业中,我已将自定义工作区设置为第一个作业的工作区,因此该作业对同一文件执行其他任务。您必须检查该选项以防止在第二个作业运行时构建第一个作业,因为两个作业都处理相同的文件,这是一种很好的做法。

但是,如果您需要并且小心的话,这可能是一个可行的解决方案。

You have several options, one is Clone Workspace, which works fairly well, but doubles the disk space needed (which in our case is quite relevant). Most other ways are a variation of Clone Workspace.

What I have done instead is to use custom workspace locations. I.e. my first job builds everything then triggers a second job. In the second job I have set the custom workspace to the workspace of the first job, so the job performs other tasks on the same files. You have to check the option to prevent a build of the first job while the second job is running though, as both work on the same files, which is kind of a fine line.

However, if you need it and are careful, this can be a viable solution.

榆西 2024-12-14 01:08:23

使用 Copy Artifact 插件 从作业 A 中复制工件(编译) 到作业 B(发布)。

Use the Copy Artifact plugin to copy artifacts from Job A (compile) to Job B (publish).

懒的傷心 2024-12-14 01:08:23

我会使用一个处理这两个子任务的主构建文件。 Ant 有一组执行任务,您可以使用它们来运行另一个 Ant 构建文件、执行一些命令行命令等。请查看此处:

http://ant.apache.org/manual/tasksoverview.html

也许您可以使用 Exec 命令启动 make,并通过使用 Ant 命令运行 Ant 构建来处理 ivy 发布。

I'd go with a master build file that handles both of the sub tasks. Ant has a set of Execution tasks that you can use to run another Ant build file, execute some command line commands, etc. Look here:

http://ant.apache.org/manual/tasksoverview.html

Perhaps you could kick off the make with an Exec command and handle the ivy publish by running an Ant build with the Ant command.

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