Using With Azure Pipelines
This example shows how to write issues as comments to an Azure DevOps pull request from an Azure Pipelines build.
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)!
-
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.
The following task will call the AzureDevOpsPullRequests alias to connect to the pull request using the environment variables provided by Azure Pipelines.
Task("ReportIssuesToPullRequest").Does(() =>
{
ReportIssuesToPullRequest(
InspectCodeIssuesFromFilePath(
@"C:\build\inspectcode.log"),
AzureDevOpsPullRequests(),
repoRootFolder);
});
Info
Please note that you'll need to setup your Azure Pipelines build to Allow scripts to access the OAuth token and need to setup proper permissions.
See OAuth authentication from Azure Pipelines for details.