If you use Azure pipelines to build and deploy your app, this blog provides detailed guidance.
In addition, if you use build number to display this version of code, you could configure run or build numbers. Also you could create build number variable(for example ProjectBuildNumber
) and make it settable in the code when building/deploying.
You could add an Inline Power-Shell task
in your build definition to update the value of ProjectBuildNumber
and then update the build number base on the it:
Write-Host "##vso[task.setvariable variable=ProjectBuildNumber;]YourUpdateValue"
Write-Host "##vso[build.updatebuildnumber]xxx.$(ProjectBuildNumber).xxx.xxx"
See this thread for more details.
BTW, you could use DevOps Starter service to build and deploy your app. See this tutorial: Set up a CI/CD pipeline for a Java app with Azure DevOps Starter for quickstart.