# How to Connect Teamscale to Azure DevOps Git

Screenshot of the Azure DevOps Plugin's Findings Badge

Teamscale integrates with Azure DevOps Server and Azure DevOps Services using the available API and web hooks. No global configuration is required. To connect a project to code from an Azure DevOps Git project, follow these steps:

TIP

Git URLs in Azure DevOps usually look like this: https://dev.azure.com/{organization}/{project}/_git/{repository}.

It is common to work on one or more projects within a single organization. Each project can have multiple Git repositories. The default Git repository has the same name as the project.

Make sure you identify the relevant parts of the repository you want to connect to before starting with this How-To.

  1. Ensure that the Teamscale instance base URL is configured correctly.

  2. Select the Azure DevOps Git connector during project creation.

  3. Select or create an account for the Azure DevOps instance. The account's fields should be filled out as follows:

    • URI: The URI is set according to the type of the Azure DevOps instance

      • Azure DevOps Services: https://dev.azure.com/{organization}
      • Azure DevOps Server: https://{instance}/{collection}
    • Username: The username can be empty; it will be ignored.

    • Password: The password is a personal access token with Code (read and write) permissions.

    Azure DevOps Services

    Entering the user's password will not work. You must use a personal access token.

    Azure DevOps Server

    The credentials for on-premise installations of Azure DevOps Server depend on the IIS configuration. If you receive the error message authentication not supported it is likely that authentication against the Git repository is tried with NTLM instead of HTTP Basic. There are two workarounds for this:

    • Enable Basic authentication in IIS Settings
    • Prefer Basic authentication over NTLM in Teamscale by passing the -Dhttp.auth.preference="basic" JVM argument on the start of Teamscale.

    Depending on your choice, you will need to use your regular username/password or the access token as credentials. Please refer to the Team Foundation Version Control documentation for more information.

  4. Complete project creation as usual, by providing the names of the Azure DevOps project and repository separated by a slash: {project}/{repository}

    Even if the project and repository names are the same, the input must be in above format (e.g., MyProject/MyProject).

As the first step during project creation, Teamscale will register its web hook with the Azure DevOps Server. After this, Teamscale will automatically be informed about events in the project, such as pushes to the repository and changes to pull requests.

# Manual Setup of Web Hooks

TIP

If there are restrictions, so that Teamscale cannot receive Azure DevOps web hooks or web hooks cannot be automatically created, please apply these advanced configuration options.

In case the user account Teamscale uses to access Azure DevOps does not have sufficient privileges to create web hooks, the web hooks need to be manually created by an Azure DevOps project administrator. Three service hooks need to be created for the following events:

  • Code pushed
  • Pull request created
  • Pull request updated
  1. In Azure DevOps, go to Project Settings > Service Hooks.

    Configuration of Azure DevOps web hooks

  2. Click the PLUS icon in the top left and select Web Hooks as service type. Click Next.

    Add Web Hook Service

  3. Configure the service hook trigger

    • Select Code pushed as event type (1).
    • Select the repository for which events will be triggered (2).
    • In case the Azure DevOps project contains more than one repository, you either have to select [Any] to trigger events for all repositories, or you have to set up hooks for each individual repository separately.
    • Click Next.

    Configure Web Hook Trigger

  4. Configure the service hook action

    • Enter the URL of the Teamscale web hook endpoint (1). The URL should be as follows: https://{teamscale-url}/api/azure-devops-git/web-hook.
    • If you use HTTPS with a self-signed certificate, Accept untrusted SSL certificates should also be checked (2).
    • Click Test to verify that the hook has been created successfully.
    • Click Finish.

    Configure Web Hook Action

  5. Repeat steps 2-4 also for event types Pull request created and Pull request updated.

# Configuring Teamscale as a required check

Screenshot describing procedure to configure Teamscale as a required check

If Teamscale is configured to vote on pull requests, you can require that all findings are addressed before a pull request is merged:

  1. In Azure DevOps, go to Project Settings > Repositories and select the repository connected to Teamscale.

  2. Select Policies and the default integration branch, e.g. master.

  3. Add a new Status Check and select Teamscale from the dropdown.