Edit

Share via


Add, remove, and use build tags

Azure DevOps Services | Azure DevOps Server 2022 | Azure DevOps Server 2020

Build tags in Azure DevOps help you categorize and organize your builds, making it easier to filter and locate specific builds. This guide walks you through adding, removing, and using build tags as part of your build management process.

Prerequisites

An Azure DevOps organization and access to a project where you're a member of the Contributors group.

Add a build tag to a completed build

Azure Pipelines UI

To add a tag to a completed build:

  1. Open your Azure DevOps project and go to Pipelines.

  2. Select the pipeline where you want to add a tag.

    Screenshot of selecting the pipeline to add a tag.

  3. Select More actions and choose Add tags to add your first tag or Edit tags if you have an existing tag.

    Screenshot of select option to add tag.

  4. Enter a tag name (for example, contoso).

    Screenshot of adding a new build tag.

  5. Press Enter to save the tag.

Azure DevOps CLI

To create a build tag, use the az pipelines build tag add command.

For example, the following command creates a build tag named prod in the contoso organization and webapp project for the build 1234.

az pipelines build tag add --build-id 1234
                           --tags prod
                           --org https://dev.azure.com/Contoso/
                           --project contoso

Output:

[
  "prod"
]

Remove a build tag

To remove build tags from your builds in Azure DevOps, follow these steps:

  1. Open your Azure DevOps project and go to Pipelines.

  2. Select the pipeline where you want to remove a tag.

  3. Select More actions and choose Edit tags.

  4. Select the X next to the tag name to remove your tag.

    Screenshot of removing build tag.

  5. Press Save to save the changes.

Add a build tag to a future build

To automatically add a build tag to a future build in a YAML pipeline, use the addbuildtag logging command.

In the following example, a new tag is added in a script task with a variable that includes the current date.

steps:
- script: |
    last_scanned="last_scanned-$(date +%Y%m%d)"
    echo "##vso[build.addbuildtag]$last_scanned"
  displayName: 'Apply last scanned tag'

Filter with a build tag

Once you've added build tags to your builds, you can use them to filter and search for specific builds. To use build tags in Azure DevOps, follow these steps:

  1. Open your Azure DevOps project and go to Pipelines.

  2. Select Runs tab.

  3. In the filter bar, select the tag you want to filter by.

    Screenshot of selecting tag to filter by.

  4. Azure DevOps filters the builds based on the specified tag, letting you find the runs you need.