在Jenkins中从多个上游作业复制工件 [英] Copying artifacts from multiple upstream jobs at join in Jenkins

查看:332
本文介绍了在Jenkins中从多个上游作业复制工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过多个上游作业的Join插件复制工件触发Jenkins作业?

Is it possible to have a Jenkins Job with has been triggered by the Join plugin copy artifacts from multiple upstream jobs?

我正在尝试使用钻石"作业来设置Jenkins配置:my-trigger运行并产生两个作业,my-fork1和my-fork2,它们可以同时运行并且花费不同的时间,并且两个插件完成后,Join插件就会启动作业my-join.

I'm trying to set-up a Jenkins configuration with a "diamond" of jobs: my-trigger runs and spawns two jobs, my-fork1 and my-fork2, that can run concurrently and take varying amounts of time, and the Join plugin sets off the job my-join once both forks have completed.

my-trigger,my-fork1和my-fork2中的每一个都会创建和指纹伪像(例如,文本文件).

Each of my-trigger, my-fork1 and my-fork2 creates and fingerprints artifacts (say, text files).

我想使用从另一个项目复制工件"工具,并将哪个构建"参数设置为触发此作业的上游构建",从my-join中复制每个上游作业的工件.但是,我在my-join的控制台中看到了这样的输出:

I want to copy the artifacts from each of the upstream jobs in my-join using the "Copy artifacts from another project" tool, with the "Which build" parameter set to "Upstream build that triggered this job". However, I see output like this in the console of my-join:

在工作区/path/to/workspace/my-join中的构建计算机上进行远程构建

Building remotely on build-machine in workspace /path/to/workspace/my-join

从"my-trigger"内部版本号63中复制了1个工件

Copied 1 artifact from "my-trigger" build number 63

从"my-fork1"内部版本号63中复制了1个工件

Copied 1 artifact from "my-fork1" build number 63

无法从以下位置找到工件副本的构建:my-fork2

Unable to find a build for artifact copy from: my-fork2

,作业失败.在这种情况下,my-fork2首先完成,因此my-fork1触发了加入步骤.我相信这意味着my-join仅记录了my-fork1和my-trigger作为上游记录.如果my-fork1首先完成,则my-fork2将启动连接,并且在尝试从my-fork1复制时作业将失败.

and the job fails. In this case, my-fork2 finished first, so my-fork1 triggered the join step. I believe that that means that my-join only has record of my-fork1 and my-trigger as being upstream. If my-fork1 finishes first, then my-fork2 kicks off the join, and the job fails when trying to copy from my-fork1.

如果我更改配置以从构建最新成功的构建"中复制工件,则构建成功,但是my-trigger可能连续运行多次,因此无法保证my-join将加入相关的工件.

If I change the configuration to copy the artifact from the build "Latest successful build" then the build succeeds, but my-trigger may run many times in succession so there would be no guarantee that my-join is joining related artifacts.

如何获得连接步骤以从多个上游分支复制工件?

How can I get the join step to copy artifacts from multiple forks upstream?

注意:这个问题的第二点似乎是问同样的事情,但唯一的答案没有解决,已被接受.

Note: the second point of this question seems to be asking the same thing, but the only answer there doesn't address it, and has been accepted.

谢谢 张量积

推荐答案

如果每次运行钻石时都使用唯一的参数对内部版本进行参数化,则可以在CopyArtifact插件中使用该参数来确定要复制的内部版本从.您可能想要指定最新成功构建",并使用参数和值对其进行限定.

If your builds are parameterized with a unique parameter for each run of the join-diamond, you can use that parameter in the CopyArtifact plugin to determine which build to copy from. You would want to specify "Latest successful build" and qualify it with the parameter and value.

我在工作时也遇到类似情况;联接钻石的多个同时运行.构建中的参数允许下游作业从上游作业中获取正确的工件.

We have a similar situation where I work; multiple simultaneous runs of a join-diamond. The parameter in the build allows the downstream jobs to get the correct artifacts from the upstream jobs.

这篇关于在Jenkins中从多个上游作业复制工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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