Azure DevOps Pipeline - Updating BuildNumber

Smajo Omanovic

I have attempted to update the build number in Azure DevOps Pipelines for quite some time now, and looked through various stackoverflow questions and documentation, and I simply cannot figure out how to fix my problem.

The Build Number I would like to set would be: $(year:yy)$(DayOfYear)$(rev:.r).

This apparently works on pipelines using the graphical interface (The pipelines were not made by me)

What I have tried so far:

- task: UpdateBuildNumber@0
  inputs:
    buildNumber: '$(year:yy)$(DayOfYear)$(rev:.r)'
Write-Host "##vso[build.updatebuildnumber]$(year:yy)$(DayOfYear)$(rev:.r)"

And a couple of variations of those as well. Each time, I get the error:

##[error]TF209010: The build number format $(year:yy)$(DayOfYear)$(rev:.r) contains invalid character(s), is too long, or ends with '.'. The maximum length of a build number is 255 characters. Characters which are not allowed include '"', '/', ':', '<', '>', '', '|', '?', '@', and '*'.

I have tried making variables for each of the dates, and using the variables instead, but that does not work either.

Any help would be greatly appreciated.

Shayki Abramczyk

It because all those variables are available only if you give it in the name: in your YAML, not in other tasks.

From the docs:

The following table shows how each token is resolved based on the previous example. You can use these tokens only to define a run number; they don't work anywhere else in your pipeline.

So, the only option it just to configure the name: $(year:yy)$(DayOfYear)$(rev:.r).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related