如何将构建工件传递给詹金斯的另一项工作 [英] How to pass build artifact into another job in Jenkins

查看:157
本文介绍了如何将构建工件传递给詹金斯的另一项工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在詹金斯(Jenkins)有两个工作:

I have two jobs in Jenkins:

  • build master-这将构建代码并创建工件
  • deploy master-这将部署工件
  • build master - this builds the code and creates an artifact
  • deploy master - this deploys the artifact

当前,deploy master具有使用最近成功构建"的从另一个项目复制工件"构建步骤.

Currently, deploy master has "Copy artifacts from another project" build step using "latest successful build".

我想将此步骤从最新成功构建"更改为由构建参数指定",以便我可以在部署时选择特定的构建,而不必每次都修改deploy master作业的配置.

I want to change this step from "latest successful build" to "specified by a build parameter" so that I can select a specific build when deploying without modifying the configuration of deploy master job each time.

首先,我更改为由构建参数指定".

First, I changed to "specified by a build parameter".

然后我选中了此项目已参数化"旁边的框,并为BUILD_SELECTOR添加了字符串参数.

Then I checked the box next to "This project is parameterized" and added a string parameter for BUILD_SELECTOR.

然后我选择了版本,然后输入输入47,它是build master作业中的内部版本号.

Then I selected build and enter the input 47 which is a build number from the build master job.

另外我尝试了api调用

Additionally I tried the api call

$.ajax({
  type: 'POST',
  url: 'https://jenkins/job/deploy%20master/build?token=abc7f5abc0c45abcea0646ed858abcde&BUILD_SELECTOR=47'
});

结果

两次均失败,并显示以下输出:

Result

Both times it failed with the following output:

Started by user styfle
[EnvInject] - Loading node environment variables.
Building in workspace C:\Jenkins\jobs\deploy master\workspace
ERROR: Unable to find a build for artifact copy from: build master
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE

问题

如何正确配置它,以便在部署时可以指定内部版本号(或其他一些标识符)?

Question

How do I configure this properly so I can specify a build number (or some other identifier) when deploying?

感谢Gerold的回答,我的解决方案是添加复制工件的构建选择器"参数,并使用新的环境变量链接到我已经添加的字符串参数.

My solution thanks to Gerold's answer was to add a "Build selector for Copy Artifact" parameter and use a new environment variable to link to my string parameter I already added.

推荐答案

在Jenkins中,每个项目/职位只有一个工作区.内部版本目录仅包含有关内部版本及其结果的信息.

There is just one workspace per project/job in Jenkins. The directories of builds contain just information about the builds and their results.

管理Jenkins 配置系统高级... 中都指定了这两个目录的根目录.

The root directories of both are specified in Manage JenkinsConfigure SystemAdvanced....

要部署先前构建的工件,您必须将其复制到build master中的其他位置,然后从deploy master中访问它.

To deploy an artifact of a previous build you have to copy it to somewhere else in build master and access it there from deploy master later.

更新:

请参见哪个版本参数名称的内联帮助:

具有此名称的参数应添加到上面的构建参数部分中.有一种特殊的参数类型可以选择构建选择器.

使用此 Build Artif for Copy Artifact (复制工件) .

Use this Build selector for Copy Artifact instead of a String Parameter.

这篇关于如何将构建工件传递给詹金斯的另一项工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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