简体   繁体   English

TFS版本管理工件变量不可用

[英]TFS Release Management Artifacts Variable not available

We want to use TFS 2015.3 Release Management for Packaging/Deploying our Software. 我们希望使用TFS 2015.3版本管理来打包/部署我们的软件。 For one of our Release Tasks we need access to the Release Artifact Variables in one of our Powershell Scripts. 对于我们的一个发布任务,我们需要在我们的Powershell脚本中访问Release Artifact Variables

But everytime we try to access one of those variables RELEASE_ARTIFACTS_[source-alias]_BUILDNUMBER for example, we receive the following error message: 但每次我们尝试访问其中一个变量RELEASE_ARTIFACTS_ [source-alias] _BUILDNUMBER时,我们收到以下错误消息:

[error] The term ' Release_Artifacts_[source-alias]_BUILDNUMBER ' is not recognized as the name of a cmdlet, function, script file, or operable program. [error]术语“ Release_Artifacts_ [source-alias] _BUILDNUMBER ”无法识别为cmdlet,函数,脚本文件或可运行程序的名称。 Check the spelling of the name, or if a path was included, verify that the path is correct and try again. 检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。

I've already tried to print out all available Environment Variables by using an inline powershell script with the following statement: Get-ChildItem Env:. 我已经尝试使用带有以下语句的内联powershell脚本打印出所有可用的环境变量:Get-ChildItem Env:。 But those variables weren't there anyway.. 但无论如何那些变量都不存在..

Are there any known issues when using Release Artifact variables? 使用Release Artifact变量时是否存在任何已知问题?

It seems that the Release Artifacts variables are not available for TFS on-prem; 似乎Release Artifacts变量不适用于TFS on-prem; I tested the same script with VSTS and with TFS2015.3. 我用VSTS和TFS2015.3测试了相同的脚本。

In VSTS release you can see the release variables in the Initialize step while in on-prem release these variables are missing: 在VSTS版本中,您可以在Initialize步骤中查看发布变量,而在本地发布时,这些变量缺失:

在此输入图像描述

在此输入图像描述

You are using the pre-defined variables of the form with Release Management Artifacts: 您正在使用发布管理工件的表单的预定义变量

RELEASE_ARTIFACTS_[source-alias]_[variable-name]

You need to replace [source-alias] with the name of the alias for the artifact source included in the release definition. 您需要将[source-alias]替换为发行版定义中包含的工件源的别名。 You can find the alias name in the Artifacts tab of a release definition. 您可以在版本定义的“ 工件”选项卡中找到别名。

在此输入图像描述

Then you could use it as below: 然后你可以使用它如下:

  • When used in an Inline Script parameter, periods in artifact names must be replaced with an underscore. Inline Script参数中使用时,工件名称中的句点必须替换为下划线。 env:RELEASE_ARTIFACTS_[ScrumProject]_[BUILDNUMBER]
  • Artifact variables can also be passed as Arguments to tasks. 工件变量也可以作为参数传递给任务。 In this case, replace the underscore with a period: Release.Artifacts.[source-alias].[variable-name] 在这种情况下,用句点替换下划线: Release.Artifacts.[source-alias].[variable-name]

More details please refer this tutorial page from MSDN: Artifacts in Microsoft Release Management 更多详细信息,请参阅MSDN中的本教程页面: Microsoft Release Management中的工件

After some test, got the same result as ds19 . 经过一些测试,得到与ds19相同的结果。 Seems release artifacts is not support for TFS2015 update3 only work with VSTS for now. 似乎发布工件不支持TFS2015 update3目前仅适用于VSTS。


Update 更新

You just need to specify build.artifactstagingdirectory in Publish Build Artifacts or Copy and Publish Build Artifacts step, TFS will do the thing for you. 您只需要在Publish Build ArtifactsCopy and Publish Build Artifacts步骤中指定build.artifactstagingdirectory ,TFS就会为您完成。 To zip the artifacts you can also use a powershell script to achieve this, more detail info you can refer this blog Manage Artifacts with TFS Build vNext 要压缩工件,您还可以使用powershell脚本来实现此目的,更多详细信息可以参考此博客使用TFS Build vNext管理工件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM