Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use $(Rev:r) in VSTS build definition?

Tags:

azure-devops

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.

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"

Error:

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

[error]PowerShell exited with code '1'.

[section]Finishing: Renaming the .MSI File

like image 969
PDBR Avatar asked Mar 07 '19 13:03

PDBR


People also ask

What is $( Rev R?

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

How do you use output variables in Azure DevOps release pipeline?

Once the output variables are defined, you can then reference them just like any other pipeline variable. One of the most common methods is using macro syntax. To reference the foo variable defined above, for example, you could use $(foo) or in the form of [originating_task name]_[variable name] .

How do you use a variable group in a release pipeline?

To use a variable group, open your pipeline. Select Variables > Variable groups, and then choose Link variable group. In a build pipeline, you see a list of available groups. In a release pipeline, for example, you also see a drop-down list of stages in the pipeline.

What is $REV in Azure DevOps?

In Azure DevOps $(rev:r) is a special variable format that only works in the Build Number field in the editor. Use $(Rev:r) to ensure that every completed build has a unique name.


1 Answers

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

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.

Source: Specify general build definition settings

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.

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.

like image 67
PatrickLu-MSFT Avatar answered Oct 13 '22 16:10

PatrickLu-MSFT