如何从 tfs 构建服务器获取工件

How to get artifacts from tfs build server

我在内部使用 TFS 2017(15.117) 构建和发布定义。 我的构建将构建结果(zip 包)推送到构建服务器上的 artifactstaging 目录。

在我的发布定义中,我有 2 个任务(管理 IIS 和部署 IIS),我想利用构建服务器上的 artifactstaging 目录来引用 zip 包,但我不知道如何使用变量...

如何使用构建定义也使用的相同代理池和队列来完成此操作?

您必须使用 Publish Artifact 任务。查看其中一个内置模板以获取示例。

使用该任务会自动将指定的二进制文件推送到您指定的位置(UNC 共享或 TFS 实例本身)。然后它根据构建结果创建一个工件 link,因此当您对构建的发布进行排队时,该发布可以自动检索与构建关联的工件。

您不需要在发布中使用额外的变量来获取构建工件。在您的发布定义设置中,有一部分 Artifact sources。 TFS 会自动将它们下载到代理。

您可以 link 对 Team Foundation Server 项目集合中 任何构建定义 的发布定义。

By default, a release created from the release definition will use the latest version of the artifacts.

At the time of linking an artifact source to a release definition, you can change this behavior by selecting one of the options to use the latest build from a specific branch by specifying the tags, a specific version, or allow the user to specify the version when the release is created from the definition.

注意:您必须在构建定义中包含一个 Publish Artifacts 任务步骤。

更多细节,建议先看MSDN官方教程:Artifacts in Release Management