From b46b487e9c88744d761eedd7e632aaa5604998c1 Mon Sep 17 00:00:00 2001 From: erich-wang Date: Thu, 16 Apr 2020 10:03:17 +0800 Subject: [PATCH] use token to get changed files for one PR on macOS (#11588) --- .../Microsoft.Azure.Build.Tasks/FilesChangedTask.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/FilesChangedTask.cs b/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/FilesChangedTask.cs index 0451eed9ea06..bd289e66d785 100644 --- a/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/FilesChangedTask.cs +++ b/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/FilesChangedTask.cs @@ -14,11 +14,12 @@ // namespace Microsoft.WindowsAzure.Build.Tasks { + using System; + using System.Collections.Generic; + using System.Runtime.InteropServices; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using Octokit; - using System.Collections.Generic; - using System; /// /// Build task to get all of the files changed in a given PR. @@ -87,7 +88,13 @@ public override bool Execute() List filesChanged = new List(); try { + //The variable is set in pipeline: "azure-powershell - powershell-core" + var token = Environment.GetEnvironmentVariable("NOSCOPEPAT_ADXSDKPS"); var client = new GitHubClient(new ProductHeaderValue("Azure")); + if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && !string.IsNullOrEmpty(token)) + { + client.Credentials = new Credentials(token); + } var files = client.PullRequest.Files(RepositoryOwner, RepositoryName, int.Parse(PullRequestNumber)) .ConfigureAwait(false).GetAwaiter().GetResult(); if (files == null)