Skip to content

use token to get changed files for one PR on macOS #11588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// Build task to get all of the files changed in a given PR.
Expand Down Expand Up @@ -87,7 +88,13 @@ public override bool Execute()
List<string> filesChanged = new List<string>();
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)
Expand Down