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
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.
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] .
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With