如何在VSTS构建定义中使用$(Rev:r)? [英] How to use $(Rev:r) in VSTS build definition?

查看:147
本文介绍了如何在VSTS构建定义中使用$(Rev:r)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要求我的构建通过私有构建代理生成abc.msi文件.现在我添加了Powershell任务以使用abc_3.0.0 $(Rev:r).msi重命名abc.msi,但Powershell任务是失败.请帮我解决这个问题.我想使用abc_3.0.0.1,abc_3.0.0.2,abc_3.0.0.3 ...等构建名称格式.随着构建的增加,$(Rev:r)的值.

I have requirement that my build is generating abc.msi file through Private build agent.Now I have added the Powershell task to rename the abc.msi with abc_3.0.0$(Rev:r).msi but The Powershell task is failing.Please help me out how to achieve this.I would like to have the build name format like abc_3.0.0.1 ,abc_3.0.0.2,abc_3.0.0.3 ...and so on.It should keep increase the value of $(Rev:r) as the builds are getting increased.

我正在运行的Powershell命令是:

The Powershell command which I am running is:

Rename-Item -Path "C:\Softwares\vsts-agent-win-x86-2.147.1\_work\1\s\src\abcSetup\Release\abc.msi" -NewName "C:\Softwares\vsts-agent-win-x86-2.147.1\_work\1\s\src\abcSetup\Release\abc_3.0.0.$(Rev:r).msi"

错误:

Rev:r:术语'Rev:r'不被识别为cmdlet的名称, 功能,脚本文件或可操作程序.检查拼写 名称,或者如果包含路径,请验证路径是否正确,以及 再试一次.在 C:\ Softwares \ vsts-agent-win-x86-2.147.1_work_temp \ fef4cc6a-e677-4a08-ab29-73c7c31da755.ps1:2 字符:243 + ... ork \ 1 \ s \ src \ abcSetup \ Release \ abc_3.0.0.$(Rev:r).msi + ~~~~~ + CategoryInfo:ObjectNotFound:(Rev:r:String)[],ParentContainsErrorRecordException + FullyQualifiedErrorId:CommandNotFoundException

Rev:r : The term 'Rev:r' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Softwares\vsts-agent-win-x86-2.147.1_work_temp\fef4cc6a-e677-4a08-ab29-73c7c31da755.ps1:2 char:243 + ... ork\1\s\src\abcSetup\Release\abc_3.0.0.$(Rev:r).msi" + ~~~~~ + CategoryInfo : ObjectNotFound: (Rev:r:String) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : CommandNotFoundException

[错误] PowerShell退出,代码为"1".

[error]PowerShell exited with code '1'.

[section]完成:重命名.MSI文件

[section]Finishing: Renaming the .MSI File

推荐答案

在Azure DevOps中,$(rev:.r)是一种特殊的变量格式,仅在编辑器的内部编号字段中有效.

In Azure DevOps $(rev:.r) is a special variable format that only works in the Build Number field in the editor.

使用$(Rev:.rr)来确保每个完成的构建都有唯一的名称. 构建完成后,如果构建号中没有其他内容 更改后,Rev整数值将增加一.

Use $(Rev:.rr) to ensure that every completed build has a unique name. When a build is completed, if nothing else in the build number has changed, the Rev integer value is incremented by one.

来源:指定常规的构建定义设置

BUILD_BUILDNUMBER是预定义的变量.如果使用此名称创建定义变量,则引用该定义变量的所有任务都将获得该变量的值,而不是系统定义的值.

BUILD_BUILDNUMBER is a predefined variable. If you create a definition variable with this name, any tasks that reference it will get this variable's value and not the system-defined value.

如果要创建一个计数器变量,可以使用counter()表达式来实现.

If you're looking to create a counter variable, you can do so with the counter() expression. See this documentation for details. It's yaml-centric but will work in the editor as well.

这篇关于如何在VSTS构建定义中使用$(Rev:r)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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