Skip to content

Integrate gitStream with Azure Boards

Learn how to integrate gitStream with Azure Boards.

Label Missing Azure Boards Info

Automatically label PRs that are missing references to Azure Boards resources.

Label Missing Azure Boards

Configuration Description

Conditions (all must be true):

  • The PR is missing one of the following:
    • An Azure Boards ticket reference in the PR title.
    • A link to an Azure Boards resource in the PR description.

Automation Actions:

  • Apply a red ⚠️ Missing Azure Boards Link label
  • Post a comment that asks the author to add an Azure Boards reference to the PR.

Label Missing Azure Boards

# -*- mode: yaml -*-

manifest:
  version: 1.0

automations:
  label_missing_azure:
    if:
      - {{not (has.azure.ticket_in_title or has.azure.ticket_in_desc)}}
    run:
      - action: add-label@v1
        args:
          label: "⚠️ Missing Azure Boards Link"
          color: {{ colors.red }}
      - action: add-comment@v1
        args:
          comment: Please provide a link to the associated resource in Azure Boards.

has:
  azure:
    ticket_in_title: {{ pr.title | includes(regex=r/(\w+)-(\w+)-(\d+)/) }}
    ticket_in_desc: {{ pr.description | includes(regex=r/(dev\.azure\.com|(\w+)\.visualstudio\.com)\/(\w+)\/(\w+)\/_workitems\/edit\/(\d+)/) }}

colors:
  red: 'b60205'

Provide automatic links to Azure Boards resources that are associated with PRs.

Automatically Link to the Related Azure Boards Resource

Configuration Description

Conditions (all must be true):

  • The PR contains a reference to an Azure Boards resource in the title or branch name.

Automation Actions:

  • Post a comment that provides a link to the associated Azure Boards Resource.

Automatically Link to the Related Azure Boards Resource

# -*- mode: yaml -*-

manifest:
  version: 1.0

# Configure these to match your organization.
provider: azure
# The name of your Azure organization
orgName: org
# The name of your Azure project
azureProject: my_project

{% set ticketid = "" %}
{% for ticket in tickets %}
{% if (ticket | includes(regex=r/.+/)) %}
{% set ticketid = ticket %}
{% endif %}
{% endfor %} 

automations:
  link_azure_boards:
    if:
      - {{ has.ticket_in_title or has.ticket_in_branch }}
    run:
      - action: add-comment@v1
        args:
          comment: Issue Tracker Link - [{{ticketid}}]({{tracker[provider].baseurl}}{{ticketid}})

has:
  ticket_in_title: {{ pr.title | includes(regex=tracker[provider].pattern) }}
  ticket_in_branch: {{ branch.name | includes(regex=tracker[provider].pattern) }}

tracker:
  azure:
    baseurl: https://dev.azure.com/[orgName]/[azureProject]/_workitems/
    pattern: r/(\w+)-(\w+)-(\d+)/

tickets:
  - {{branch.name | capture(regex=tracker[provider].pattern)}}
  - {{pr.title | capture(regex=tracker[provider].pattern)}}

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.