如何从另一个 job2 访问 Hudson job1 工件?

发布于 2024-10-22 04:01:55 字数 82 浏览 4 评论 0原文

我们在哈德逊的一个项目中有一份制作工作和一份夜间工作。生产作业需要从特定的夜间构建#(作为参数提供)中提取一些工件。谁能帮助我们提示如何实现这一目标?

We have a production job and a nightly job for a project in Hudson. The production job needs to pull off some artifacts from a specific nightly build # (which is provided as parameter). Can anyone help us with a hint on how to achieve this?

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

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

发布评论

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

评论(3

肤浅与狂妄 2024-10-29 04:01:55

Copy Artifact 插件似乎能够做到这一点。

另一种方法可能是通过获取工件

http://server/jobs/job1/[build #]/artifacts/

The Copy Artifact plugin seems to be capable of doing this.

Another approach could be to fetch the artifact via

http://server/jobs/job1/[build #]/artifacts/
小…红帽 2024-10-29 04:01:55

您可以使用作业配置页面中的“构建环境”配置工具。勾选“配置 M2 额外构建步骤”框并添加一个执行 Shell,用于从所需工件中 grep 内容。

You can use "Build Environment" configuration tools in the job's configuration page. Tick the Configure M2 Extra Build Steps box and add an Execute Shell which grep things from the desired artifact.

情未る 2024-10-29 04:01:55

我们有类似的需求并使用以下系统常规:

import hudson.model.*

def currentBuild = Thread.currentThread().executable;
currentBuild.addAction(new ParametersAction(new StringParameterValue('LAST_BUILD_STATUS', 'FAILURE')));
def buildJob = Hudson.instance.getJob("ArtifactJobName");
def artifacts = buildJob.getLastBuild().getArtifacts();
if (buildJob.getLastBuild().getResult() == Result.SUCCESS && artifacts != null && artifacts.size() > 0) {
    currentBuild.addAction(new ParametersAction(new StringParameterValue('VARIABLE_NAME', artifacts[0].getFileName())));
    currentBuild.addAction(new ParametersAction(new StringParameterValue('LAST_BUILD_STATUS', 'SUCCESS')));
}

这会创建一个 VARIABLE_NAME,其中包含来自 ArtifactJobName 的工件名称,我们使用它,因为它们都存储在特定文件夹中。我不确定如果您有多个工件会发生什么,但似乎您可以从工件数组中获取它们。

您可以使用 getLastSuccessfulBuild 来防止当前正在构建另一个 ArtifactJobName 且您获取的数组为 null 时出现问题。

We have similar need and use the following system groovy:

import hudson.model.*

def currentBuild = Thread.currentThread().executable;
currentBuild.addAction(new ParametersAction(new StringParameterValue('LAST_BUILD_STATUS', 'FAILURE')));
def buildJob = Hudson.instance.getJob("ArtifactJobName");
def artifacts = buildJob.getLastBuild().getArtifacts();
if (buildJob.getLastBuild().getResult() == Result.SUCCESS && artifacts != null && artifacts.size() > 0) {
    currentBuild.addAction(new ParametersAction(new StringParameterValue('VARIABLE_NAME', artifacts[0].getFileName())));
    currentBuild.addAction(new ParametersAction(new StringParameterValue('LAST_BUILD_STATUS', 'SUCCESS')));
}

This creates a VARIABLE_NAME with the artifact name in it from ArtifactJobName, which we use since they are all stored in a specific folder. I am not sure what will happen if you have multiple artifacts, but it seems you could get them from the artifacts array.

You could use getLastSuccessfulBuild to prevent issue when another ArtifactJobName is being build at the moment and you get array with null.

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