Raymond Raymond / Microsoft Azure

Access Artifact BuildNumber in Azure DevOps Release Pipeline

event 2019-12-01 visibility 7,172 comment 0 insights toc
insights Stats
toc Table of contents
Access Artifact BuildNumber in Azure DevOps Release Pipeline

It might be useful to push artifact or build variables to your Azure websites environment variables in Release pipelines. 

In this article, I'm going to show you how to add build number in Build pipeline to your Azure website when publishing using Release pipeline in Azure DevOps. For this website, the build number is also shown in page footer for reference. 


Available variables

Refer to the following link to find out the complete list of available environment variables that you can use in Release pipelines.


For build number, we will use this particular variable:


The build number or the commit identifier.

Azure pipelines example: 20170112.1

Jenkins/TeamCity example: 20170112.1

TFVC example: Changeset 3

Git example: 38629c964

GitHub example: 38629c964

Use variable

In Azure App Service Deploy task in my release job, update App settings in Application and Configuration Settings section to add the following value:


This step will add an environment variable named KONTEXT_BUILD_NUMBER to my ASP.NET Core application settings when doing the deployment.

Please note 'Starlink-ASP.NET Core-CI' is the artifact alias for my website build artifact. You need to replace it accordingly to your own artifact alias. 

Run the release pipeline

And then you can run the release pipeline. In the output logs, you can see the application settings is added. 


Check the application settings in Azure App Service

In Azure portal, you can also find the new settings in Settings > Configurations > Application Settings



Build number is just one of the artifact variables that you can use in release pipelines and you can use any other available variables in your Release pipelines. You can also configure this in pipeline yml file instead of using the Classic UI.

If you want to use the environment variables in PowerShell, the naming will be slightly different. For example, the build number environment name for my artifact is:


To save your time, you can find all the available environment variable names in Initialize Job step in your release pipeline as the following screenshot shows:


More from Kontext
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts