Search code examples
azure-devopsazure-pipelines

Create a counter variable in Azure Devops for every pipeline successful run


I would like to create a variable in Azure Devops that starts with 0 and increases by 1 for every successful pipeline run.

I have tried creating a variable in the pipeline(in the YAML file) and increase it's value every time the pipeline runs successful but it seems that it's value resets to 0 with the variable declaration.

I have tried creating a library variable but the value never increases.


Solution

  • You can't do this with variables alone, but there is a counter function that will do what you want.

    There is also a special variable called $(Rev.R) which can only be used as part of the build number which will increment by 1. This will reset if another part of the build number changes so it might not be what you need