How to Link Azure DevOps Tickets to GitHub Pull Requests

How to Link Azure DevOps Tickets to GitHub Pull Requests

In today’s collaborative development environment, linking Azure DevOps tickets to GitHub pull requests enhances the traceability of work, facilitates smooth collaboration between teams, and improves productivity. This integration ensures that developers can track work items, bugs, and tasks directly from GitHub pull requests while using Azure DevOps for project management and tracking. In this article, we will explore how to efficiently link Azure DevOps tickets to GitHub pull requests.

1. Understand the Integration Basics

Before diving into the steps, let’s understand what we are aiming to achieve. The goal is to establish a connection between Azure DevOps work items (tasks, user stories, bugs, etc.) and GitHub pull requests. This linkage will:

  • Provide visibility on the progress of work.
  • Automatically update Azure DevOps work items when a pull request is created, updated, or merged.
  • Help teams maintain traceability between the code changes and project management tasks.

Azure DevOps offers built-in tools and extensions that enable integration with third-party services like GitHub.

2. Use Azure Pipelines for GitHub Integration

One way to link Azure DevOps work items to GitHub pull requests is by using Azure Pipelines in combination with GitHub. Azure Pipelines is a continuous integration and delivery (CI/CD) service that can be integrated with both Azure DevOps and GitHub.

Here’s how to set it up:

  • Create a Pipeline in Azure DevOps: Start by setting up an Azure Pipeline for your project. You can create a pipeline that integrates with your GitHub repository.
  • Configure the GitHub Repository: In the Azure Pipeline settings, link your GitHub repository where your pull requests are managed. This integration ensures Azure DevOps tracks changes in GitHub and provides seamless interaction with Azure work items.
  • Enable GitHub Commit Messages to Link Work Items: You can use the GitHub commit message syntax (like Fixes #WorkItemID or Closes #WorkItemID) in your pull requests. When a developer pushes commits related to a specific Azure DevOps work item, the ID (e.g., #1234) can be included in the commit message, automatically linking the pull request to the work item.

3. Use Azure DevOps GitHub Integration Extension

Azure DevOps also offers a GitHub integration extension that connects GitHub repositories with Azure Boards (work items). This extension helps streamline the process of linking Azure DevOps work items with GitHub commits and pull requests.

Here’s how to set it up:

  • Install the GitHub Extension for Azure DevOps: Go to the Azure DevOps marketplace and install the GitHub for Azure DevOps extension. This extension provides additional capabilities such as associating commits and pull requests with Azure DevOps work items.
  • Link GitHub Pull Requests to Azure DevOps Work Items:
    • In your pull request description in GitHub, reference the Azure DevOps work item by including the work item ID. For example, use AB#1234 to reference work item 1234 in Azure DevOps.
    • When the pull request is merged, the work item will automatically be updated with a status change (e.g., “Resolved” or “Completed”).

4. Linking via Commit Messages

One of the simplest methods to link Azure DevOps tickets with GitHub pull requests is through commit messages. By referencing Azure DevOps work item IDs directly in your commit messages, you can ensure the connection is established automatically.

  • Format: Use the format Fixes AB#1234 or Closes AB#1234 in the commit message to link the commit (and subsequently the pull request) to a specific Azure DevOps work item.
    • AB refers to the prefix used in Azure DevOps work items.
    • 1234 is the work item ID.

When the pull request is merged, Azure DevOps will automatically update the associated work item, moving it to the next stage (e.g., from “In Progress” to “Closed”).

5. Enable Smart Commits in GitHub

Another powerful way to link GitHub pull requests to Azure DevOps tickets is through smart commits. These are specific commit messages that trigger actions within Azure DevOps.

  • Example: You can use smart commits like AB#1234 Fix issue with login or AB#1234 Completed feature implementation.
  • These commits will trigger updates in Azure DevOps automatically based on the defined syntax, helping maintain a real-time link between the GitHub pull request and the Azure DevOps work item.

6. Review and Track Progress in Azure DevOps

Once the GitHub pull request is linked to an Azure DevOps work item, you can easily track progress directly within Azure DevOps. The work item will display details such as:

  • Pull Request Status: Whether the pull request has been opened, reviewed, or merged.
  • Linked Commit Details: Any commits made to GitHub that reference this work item, and their status.
  • Completion Status: Once the pull request is merged, the associated work item can automatically be marked as complete or resolved.

7. Automate with GitHub Actions and Azure DevOps

If you’re using GitHub Actions for CI/CD in GitHub, you can set up an automated workflow that updates Azure DevOps work items based on pull request status. For instance, you can configure an action to:

  • Update the Azure DevOps ticket when a pull request is merged.
  • Send a notification to the Azure DevOps team when a pull request is linked to a specific work item.

This workflow can be customized based on your team’s needs, and it ensures seamless tracking between the two platforms.

8. Check Permissions and Security

While linking Azure DevOps work items to GitHub pull requests, ensure that the necessary permissions and security settings are configured. Both systems should have the appropriate access controls to allow integration, such as:

  • Azure DevOps Permissions: Ensure that developers have permission to modify and update work items.
  • GitHub Permissions: Make sure your GitHub repository has appropriate access for pushing commits that reference Azure DevOps work items.

9. Additional Tools for Integration

There are several third-party tools and services available that offer enhanced integration between Azure DevOps and GitHub. For example, tools like Zapier and GitHub Webhooks can automate workflows and create custom triggers for linking work items and pull requests.

Leave a Reply