Using With Pull Request ID

This example shows how to write issues as comments to an Azure DevOps pull request while using pull request id.

To determine the remote repository URL you need the Cake.Git addin:

#addin "Cake.Git" // (1)!
  1. In production code this dependency should be pinned to a specific version to make sure builds are deterministic and won't break due to updates.

    See Reproducible Builds for details.

To write issues as comments to Azure DevOps pull requests you need to import the core addin, the core pull request addin, the Azure DevOps support including the Cake.AzureDevOps addin, and one or more issue providers, in this example for JetBrains InspectCode:

#addin nuget:?package=Cake.Issues&version=5.0.1
#addin nuget:?package=Cake.Issues.InspectCode&version=5.0.1
#addin nuget:?package=Cake.Issues.PullRequests&version=5.0.1
#addin nuget:?package=Cake.Issues.PullRequests.AzureDevOps&version=5.0.1
#addin "Cake.AzureDevOps" // (1)!
  1. In production code this dependency should be pinned to a specific version to make sure builds are deterministic and won't break due to updates.

    See Reproducible Builds for details.

In the following task we'll first determine the remote repository URL and with this information call the AzureDevOpsPullRequests alias, which will authenticate through NTLM to an on-premise Azure DevOps Server instance:

Task("ReportIssuesToPullRequest").Does(() =>
{
    var repoRootFolder = MakeAbsolute(Directory("./"));
    var repoRemoteUrl = new Uri(currentBranch.Remotes.Single(x => x.Name == "origin").Url);
    var pullRequestId = 123;

    ReportIssuesToPullRequest(
        InspectCodeIssuesFromFilePath(
            @"C:\build\inspectcode.log"),
        AzureDevOpsPullRequests(
            repoRemoteUrl,
            pullRequestId,
            AzureDevOpsAuthenticationNtlm()),
        repoRootFolder);
});