Skip to content

Commit d15ce70

Browse files
authored
Fix the issue for forked branch (Azure#19429)
Co-authored-by: wyunchi-ms <[email protected]>
1 parent 192066a commit d15ce70

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks/FilesChangedTask.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,19 @@ public override bool Execute()
102102
//The variable is set in pipeline: "azure-powershell - powershell-core"
103103
var client = new GitHubClient(new ProductHeaderValue("Azure"));
104104
client.Credentials = new Credentials(Environment.GetEnvironmentVariable("OCTOKITPAT"));
105-
var files = client.PullRequest.Files(RepositoryOwner, RepositoryName, int.Parse(PullRequestNumber))
106-
.ConfigureAwait(false).GetAwaiter().GetResult();
105+
IReadOnlyList<PullRequestFile> files;
106+
try
107+
{
108+
files = client.PullRequest.Files(RepositoryOwner, RepositoryName, int.Parse(PullRequestNumber))
109+
.ConfigureAwait(false).GetAwaiter().GetResult();
110+
}
111+
catch (AuthorizationException e)
112+
{
113+
client.Credentials = null;
114+
files = client.PullRequest.Files(RepositoryOwner, RepositoryName, int.Parse(PullRequestNumber))
115+
.ConfigureAwait(false).GetAwaiter().GetResult();
116+
}
117+
107118
if (files == null)
108119
{
109120
return false;

0 commit comments

Comments
 (0)