Use AuthToken for cal to Search API (#6624)
Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
This commit is contained in:
parent
0676c77217
commit
257e9f466a
@ -132,7 +132,7 @@ function Set-ApiViewCommentForRelatedIssues {
|
||||
. ${PSScriptRoot}\..\common.ps1
|
||||
$issuesForCommit = $null
|
||||
try {
|
||||
$issuesForCommit = Search-GitHubIssues -CommitHash $HeadCommitish
|
||||
$issuesForCommit = Search-GitHubIssues -CommitHash $HeadCommitish -AuthToken $AuthToken
|
||||
if ($issuesForCommit.items.Count -eq 0) {
|
||||
LogInfo "No issues found for commit: $HeadCommitish"
|
||||
Write-Host "##vso[task.complete result=SucceededWithIssues;]DONE"
|
||||
|
||||
@ -560,12 +560,17 @@ function Search-GitHubIssues {
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Parameter(Mandatory = $true)]
|
||||
$CommitHash,
|
||||
$State="open"
|
||||
$State="open",
|
||||
$AuthToken
|
||||
)
|
||||
$uri = "https://api.github.com/search/issues?q=sha:$CommitHash+state:$State"
|
||||
|
||||
return Invoke-RestMethod `
|
||||
-Method GET `
|
||||
-Uri $uri `
|
||||
-MaximumRetryCount 3
|
||||
$params = @{
|
||||
Method = 'GET'
|
||||
Uri = $uri
|
||||
MaximumRetryCount = 3
|
||||
}
|
||||
if ($AuthToken) {
|
||||
$params.Headers = Get-GitHubApiHeaders -token $AuthToken
|
||||
}
|
||||
return Invoke-RestMethod @params
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user