-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync eng/common directory with azure-sdk-tools for PR 1052 (#12650)
* Update location of patch files * Add some changes in eng/common to test things * Switch to pushing to upstream * Change workflow to use upstream branches Co-authored-by: Chidozie Ononiwu <[email protected]>
- Loading branch information
1 parent
f805ad7
commit 531075e
Showing
6 changed files
with
135 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
[CmdletBinding(SupportsShouldProcess = $true)] | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[string]$RepoOwner, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string]$RepoName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string]$IssueNumber, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[string]$CommentPrefix, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string]$Comment, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[string]$CommentPostFix, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string]$AuthToken | ||
) | ||
|
||
. "${PSScriptRoot}\logging.ps1" | ||
|
||
$headers = @{ | ||
Authorization = "bearer $AuthToken" | ||
} | ||
|
||
$apiUrl = "https://api.github.com/repos/$RepoOwner/$RepoName/issues/$IssueNumber/comments" | ||
|
||
$commentPrefixValue = [System.Environment]::GetEnvironmentVariable($CommentPrefix) | ||
$commentValue = [System.Environment]::GetEnvironmentVariable($Comment) | ||
$commentPostFixValue = [System.Environment]::GetEnvironmentVariable($CommentPostFix) | ||
|
||
if (!$commentPrefixValue) { $commentPrefixValue = $CommentPrefix } | ||
if (!$commentValue) { $commentValue = $Comment } | ||
if (!$commentPostFixValue) { $commentPostFixValue = $CommentPostFix } | ||
|
||
$PRComment = "$commentPrefixValue $commentValue $commentPostFixValue" | ||
|
||
$data = @{ | ||
body = $PRComment | ||
} | ||
|
||
try { | ||
$resp = Invoke-RestMethod -Method POST -Headers $headers -Uri $apiUrl -Body ($data | ConvertTo-Json) | ||
} | ||
catch { | ||
LogError "Invoke-RestMethod [ $apiUrl ] failed with exception:`n$_" | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
[CmdletBinding(SupportsShouldProcess = $true)] | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[string]$Organization, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string]$Project, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string]$SourceBranch, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[int]$DefinitionId, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[string]$VsoQueuedPipelines, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string]$AuthToken | ||
) | ||
|
||
. "${PSScriptRoot}\logging.ps1" | ||
|
||
$headers = @{ | ||
Authorization = "Basic $AuthToken" | ||
} | ||
|
||
$apiUrl = "https://dev.azure.com/$Organization/$Project/_apis/build/builds?api-version=6.0" | ||
|
||
$body = @{ | ||
sourceBranch = $SourceBranch | ||
definition = @{ id = $DefinitionId } | ||
} | ||
|
||
Write-Verbose ($body | ConvertTo-Json) | ||
|
||
try { | ||
$resp = Invoke-RestMethod -Method POST -Headers $headers $apiUrl -Body ($body | ConvertTo-Json) -ContentType application/json | ||
} | ||
catch { | ||
LogError "Invoke-RestMethod [ $apiUrl ] failed with exception:`n$_" | ||
exit 1 | ||
} | ||
|
||
LogDebug "Pipeline [ $($resp.definition.name) ] queued at [ $($resp._links.web.href) ]" | ||
|
||
if ($VsoQueuedPipelines) { | ||
$enVarValue = [System.Environment]::GetEnvironmentVariable($VsoQueuedPipelines) | ||
$QueuedPipelineLinks = if ($enVarValue) { | ||
"$enVarValue<br>[$($resp.definition.name)]($($resp._links.web.href))" | ||
}else { | ||
"[$($resp.definition.name)]($($resp._links.web.href))" | ||
} | ||
$QueuedPipelineLinks | ||
Write-Host "##vso[task.setvariable variable=$VsoQueuedPipelines]$QueuedPipelineLinks" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,10 @@ param( | |
[string] $GitUrl, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[string] $PushArgs = "" | ||
[string] $PushArgs = "", | ||
|
||
[Parameter(Mandatory = $false)] | ||
[boolean] $SkipCommit = $false | ||
) | ||
|
||
# This is necessay because of the janky git command output writing to stderr. | ||
|
@@ -57,12 +60,17 @@ if ($LASTEXITCODE -ne 0) | |
exit $LASTEXITCODE | ||
} | ||
|
||
Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"[email protected]`" commit -am `"$($CommitMsg)`"" | ||
git -c user.name="azure-sdk" -c user.email="[email protected]" commit -am "$($CommitMsg)" | ||
if ($LASTEXITCODE -ne 0) | ||
{ | ||
Write-Error "Unable to add files and create commit LASTEXITCODE=$($LASTEXITCODE), see command output above." | ||
exit $LASTEXITCODE | ||
if (!$SkipCommit) { | ||
Write-Host "git -c user.name=`"azure-sdk`" -c user.email=`"[email protected]`" commit -am `"$($CommitMsg)`"" | ||
git -c user.name="azure-sdk" -c user.email="[email protected]" commit -am "$($CommitMsg)" | ||
if ($LASTEXITCODE -ne 0) | ||
{ | ||
Write-Error "Unable to add files and create commit LASTEXITCODE=$($LASTEXITCODE), see command output above." | ||
exit $LASTEXITCODE | ||
} | ||
} | ||
else { | ||
Write-Host "Skipped applying commit" | ||
} | ||
|
||
# The number of retries can be increased if necessary. In theory, the number of retries | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters