让 Jenkins(Hudson)的工作依赖于另一份工作

发布于 2024-08-30 01:51:05 字数 431 浏览 8 评论 0原文

我有两项工作:

  1. 上传
  2. 启动实例

我想让启动实例依赖于另一项工作,以便触发启动-instance 自动导致首先运行上传

我可以使用内置 Jenkins 功能或插件来实现此目的吗?

请注意,我希望上传始终触发启动实例,这就是上的“构建其他项目后构建”选项。 em>启动实例就可以了。我想要的是类似于 depends 属性在 Ant 中的工作方式

I have two jobs:

  1. Upload
  2. Launch-instance

I want to make Launch-instance dependent on the other one, so that triggering Launch-instance automatically causes Upload to be run first.

Can I achieve this using built-in Jenkins features or with a plugin?

Note that I do not want Upload to always trigger Launch-instance, which is what the "Build after other projects are built" option on Launch-instance would do. What I want is more analogous to how depends attribute works in Ant.

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

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

发布评论

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

评论(5

<逆流佳人身旁 2024-09-06 01:51:05

您是否尝试过参数化触发器插件

您可以将其用作构建步骤,并标记“阻止直到触发的项目完成其构建”复选框。这应该正是您正在寻找的。

Have you tried the Parametrized Trigger Plugin?

You can use it as a build step, and mark the checkbox for "Block until the triggered projects finish their builds". That should be exactly what you are looking for.

知足的幸福 2024-09-06 01:51:05

啊哈,找到了!在这里,我正在建立miki的答案< /a> 它指明了道路,但没有完全为我解决这个问题。

正如有关启动 Hudson 的西班牙语文章中所述构建,这是从 Hudson 的

En la sección“构建触发器”[...] marcamos la
选项“触发器远程构建(例如,
来自脚本)
”。Al marcar esta opción vemos como aparece el cuadro de texto “Authentication Token”。Aquí pondremos el nombre del token de autenticación。

alt text
(来源:adictosaltrabajo.com

(似乎了解西班牙语的好处开始显现......:-)

因此,Hudson 提供了一个方便的内置选项来远程触发构建。在构建触发器部分(在我的例子中是上传作业),您可以启用远程构建并设置身份验证令牌(请参见上面的屏幕截图)。然后,您可以通过访问包含该令牌的特定 URL 来启动构建。就我而言,Launch-instance 的第一个构建步骤如下所示:

wget http://[hudson-url]/job/Upload/build?token=TEST
sleep 10

即使禁用匿名构建,并且仅尝试访问构建 URL 将产生“403 Forbidden”,该步骤也能正常工作。

Aha, found it! Here I'm building on miki's answer which showed the way but didn't fully solve this for me.

As it says in the Spanish-language article about launching Hudson builds which was linked to from the comments of Hudson's Remote access API page that miki linked to:

En la sección "Build Triggers" [...] marcamos la
opción "Trigger builds remotely (e.g.,
from scripts)
". Al marcar esta opción vemos como aparece el cuadro de texto "Authentication Token". Aquí pondremos el nombre del token de autenticación.

alt text
(source: adictosaltrabajo.com)

(It seems the benefits of knowing Spanish are starting to materialise... :-)

So, turns out Hudson provides a handy built-in option for triggering builds remotely. In Build Triggers section (of Upload job in my case) you can enable remote builds and set an auth token (see screenshot above). Then you can launch a build by accessing a certain URL containing that token. In my case, the first build step of Launch-instance looks like:

wget http://[hudson-url]/job/Upload/build?token=TEST
sleep 10

This works even if anonymous builds are disabled and simply trying to access the build URL would yield "403 Forbidden".

你的呼吸 2024-09-06 01:51:05

通过调用 使用 wget 作为第一个构建步骤构建 URL?然后添加Launch-instance的重要构建步骤。

或者,对于更高级的方法,可以使用 远程访问 API

What about building Upload by calling its build URL with wget as the first build step? Then adding the beef build steps of Launch-instance.

Or for a fancier approach, perhaps use the Remote access API.

茶色山野 2024-09-06 01:51:05

通过 wget 运行依赖作业并不是通用的解决方案。由于作业是异步运行的,因此您的启动作业不会挂起并等待上传作业完成。使用 sleep 只是一种肮脏的黑客行为,在大多数情况下不是一个选择......
恕我直言,最好的解决方案是使用: http://wiki.jenkins-ci.org /显示/JENKINS/加入+插件

Running dependent job via wget is not a general solution. Since jobs are run asynchornnously your Launch-job will not be hang and wait for Upload job for a completion. using sleep is just a dirty hack and is not an option for most cases...
IMHO the best solution is to use: http://wiki.jenkins-ci.org/display/JENKINS/Join+Plugin

十二 2024-09-06 01:51:05

您可以使用下游或上游依赖项。您应该使用“构建触发器”->
在构建其他项目之后构建和/或在项目的配置部分中进行构建后操作。

You can use the downstream or upstream dependencies. You should use "Build Triggers" ->
Build after other projects are built and/or post-build actions in the configure part of the project.

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