You've already forked linux-packaging-mono
Imported Upstream version 6.6.0.89
Former-commit-id: b39a328747c2f3414dc52e009fb6f0aa80ca2492
This commit is contained in:
parent
cf815e07e0
commit
95fdb59ea6
35
external/linker/eng/common/post-build/darc-gather-drop.ps1
vendored
Normal file
35
external/linker/eng/common/post-build/darc-gather-drop.ps1
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][int] $BarBuildId, # ID of the build which assets should be downloaded
|
||||
[Parameter(Mandatory=$true)][string] $DropLocation, # Where the assets should be downloaded to
|
||||
[Parameter(Mandatory=$true)][string] $MaestroApiAccessToken, # Token used to access Maestro API
|
||||
[Parameter(Mandatory=$false)][string] $MaestroApiEndPoint = "https://maestro-prod.westus2.cloudapp.azure.com", # Maestro API URL
|
||||
[Parameter(Mandatory=$false)][string] $MaestroApiVersion = "2019-01-16" # Version of Maestro API to use
|
||||
)
|
||||
|
||||
. $PSScriptRoot\post-build-utils.ps1
|
||||
|
||||
try {
|
||||
Write-Host "Installing DARC ..."
|
||||
|
||||
. $PSScriptRoot\..\darc-init.ps1
|
||||
$exitCode = $LASTEXITCODE
|
||||
|
||||
if ($exitCode -ne 0) {
|
||||
Write-PipelineTaskError "Something failed while running 'darc-init.ps1'. Check for errors above. Exiting now..."
|
||||
ExitWithExitCode $exitCode
|
||||
}
|
||||
|
||||
darc gather-drop --non-shipping `
|
||||
--continue-on-error `
|
||||
--id $BarBuildId `
|
||||
--output-dir $DropLocation `
|
||||
--bar-uri $MaestroApiEndpoint `
|
||||
--password $MaestroApiAccessToken `
|
||||
--latest-location
|
||||
}
|
||||
catch {
|
||||
Write-Host $_
|
||||
Write-Host $_.Exception
|
||||
Write-Host $_.ScriptStackTrace
|
||||
ExitWithExitCode 1
|
||||
}
|
25
external/linker/eng/common/post-build/nuget-validation.ps1
vendored
Normal file
25
external/linker/eng/common/post-build/nuget-validation.ps1
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# This script validates NuGet package metadata information using this
|
||||
# tool: https://github.com/NuGet/NuGetGallery/tree/jver-verify/src/VerifyMicrosoftPackage
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string] $PackagesPath, # Path to where the packages to be validated are
|
||||
[Parameter(Mandatory=$true)][string] $ToolDestinationPath # Where the validation tool should be downloaded to
|
||||
)
|
||||
|
||||
. $PSScriptRoot\post-build-utils.ps1
|
||||
|
||||
try {
|
||||
$url = "https://raw.githubusercontent.com/NuGet/NuGetGallery/jver-verify/src/VerifyMicrosoftPackage/verify.ps1"
|
||||
|
||||
New-Item -ItemType "directory" -Path ${ToolDestinationPath} -Force
|
||||
|
||||
Invoke-WebRequest $url -OutFile ${ToolDestinationPath}\verify.ps1
|
||||
|
||||
& ${ToolDestinationPath}\verify.ps1 ${PackagesPath}\*.nupkg
|
||||
}
|
||||
catch {
|
||||
Write-PipelineTaskError "NuGet package validation failed. Please check error logs."
|
||||
Write-Host $_
|
||||
Write-Host $_.ScriptStackTrace
|
||||
ExitWithExitCode 1
|
||||
}
|
90
external/linker/eng/common/post-build/post-build-utils.ps1
vendored
Normal file
90
external/linker/eng/common/post-build/post-build-utils.ps1
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
# Most of the functions in this file require the variables `MaestroApiEndPoint`,
|
||||
# `MaestroApiVersion` and `MaestroApiAccessToken` to be globally available.
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Set-StrictMode -Version 2.0
|
||||
|
||||
# `tools.ps1` checks $ci to perform some actions. Since the post-build
|
||||
# scripts don't necessarily execute in the same agent that run the
|
||||
# build.ps1/sh script this variable isn't automatically set.
|
||||
$ci = $true
|
||||
. $PSScriptRoot\..\tools.ps1
|
||||
|
||||
function Create-MaestroApiRequestHeaders([string]$ContentType = "application/json") {
|
||||
Validate-MaestroVars
|
||||
|
||||
$headers = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]'
|
||||
$headers.Add('Accept', $ContentType)
|
||||
$headers.Add('Authorization',"Bearer $MaestroApiAccessToken")
|
||||
return $headers
|
||||
}
|
||||
|
||||
function Get-MaestroChannel([int]$ChannelId) {
|
||||
Validate-MaestroVars
|
||||
|
||||
$apiHeaders = Create-MaestroApiRequestHeaders
|
||||
$apiEndpoint = "$MaestroApiEndPoint/api/channels/${ChannelId}?api-version=$MaestroApiVersion"
|
||||
|
||||
$result = try { Invoke-WebRequest -Method Get -Uri $apiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" }
|
||||
return $result
|
||||
}
|
||||
|
||||
function Get-MaestroBuild([int]$BuildId) {
|
||||
Validate-MaestroVars
|
||||
|
||||
$apiHeaders = Create-MaestroApiRequestHeaders -AuthToken $MaestroApiAccessToken
|
||||
$apiEndpoint = "$MaestroApiEndPoint/api/builds/${BuildId}?api-version=$MaestroApiVersion"
|
||||
|
||||
$result = try { return Invoke-WebRequest -Method Get -Uri $apiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" }
|
||||
return $result
|
||||
}
|
||||
|
||||
function Get-MaestroSubscriptions([string]$SourceRepository, [int]$ChannelId) {
|
||||
Validate-MaestroVars
|
||||
|
||||
$SourceRepository = [System.Web.HttpUtility]::UrlEncode($SourceRepository)
|
||||
$apiHeaders = Create-MaestroApiRequestHeaders -AuthToken $MaestroApiAccessToken
|
||||
$apiEndpoint = "$MaestroApiEndPoint/api/subscriptions?sourceRepository=$SourceRepository&channelId=$ChannelId&api-version=$MaestroApiVersion"
|
||||
|
||||
$result = try { Invoke-WebRequest -Method Get -Uri $apiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" }
|
||||
return $result
|
||||
}
|
||||
|
||||
function Trigger-Subscription([string]$SubscriptionId) {
|
||||
Validate-MaestroVars
|
||||
|
||||
$apiHeaders = Create-MaestroApiRequestHeaders -AuthToken $MaestroApiAccessToken
|
||||
$apiEndpoint = "$MaestroApiEndPoint/api/subscriptions/$SubscriptionId/trigger?api-version=$MaestroApiVersion"
|
||||
Invoke-WebRequest -Uri $apiEndpoint -Headers $apiHeaders -Method Post | Out-Null
|
||||
}
|
||||
|
||||
function Assign-BuildToChannel([int]$BuildId, [int]$ChannelId) {
|
||||
Validate-MaestroVars
|
||||
|
||||
$apiHeaders = Create-MaestroApiRequestHeaders -AuthToken $MaestroApiAccessToken
|
||||
$apiEndpoint = "$MaestroApiEndPoint/api/channels/${ChannelId}/builds/${BuildId}?api-version=$MaestroApiVersion"
|
||||
Invoke-WebRequest -Method Post -Uri $apiEndpoint -Headers $apiHeaders | Out-Null
|
||||
}
|
||||
|
||||
function Validate-MaestroVars {
|
||||
try {
|
||||
Get-Variable MaestroApiEndPoint -Scope Global | Out-Null
|
||||
Get-Variable MaestroApiVersion -Scope Global | Out-Null
|
||||
Get-Variable MaestroApiAccessToken -Scope Global | Out-Null
|
||||
|
||||
if (!($MaestroApiEndPoint -Match "^http[s]?://maestro-(int|prod).westus2.cloudapp.azure.com$")) {
|
||||
Write-PipelineTaskError "MaestroApiEndPoint is not a valid Maestro URL. '$MaestroApiEndPoint'"
|
||||
ExitWithExitCode 1
|
||||
}
|
||||
|
||||
if (!($MaestroApiVersion -Match "^[0-9]{4}-[0-9]{2}-[0-9]{2}$")) {
|
||||
Write-PipelineTaskError "MaestroApiVersion does not match a version string in the format yyyy-MM-DD. '$MaestroApiVersion'"
|
||||
ExitWithExitCode 1
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-PipelineTaskError "Error: Variables `MaestroApiEndPoint`, `MaestroApiVersion` and `MaestroApiAccessToken` are required while using this script."
|
||||
Write-Host $_
|
||||
ExitWithExitCode 1
|
||||
}
|
||||
}
|
48
external/linker/eng/common/post-build/promote-build.ps1
vendored
Normal file
48
external/linker/eng/common/post-build/promote-build.ps1
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][int] $BuildId,
|
||||
[Parameter(Mandatory=$true)][int] $ChannelId,
|
||||
[Parameter(Mandatory=$true)][string] $MaestroApiAccessToken,
|
||||
[Parameter(Mandatory=$false)][string] $MaestroApiEndPoint = "https://maestro-prod.westus2.cloudapp.azure.com",
|
||||
[Parameter(Mandatory=$false)][string] $MaestroApiVersion = "2019-01-16"
|
||||
)
|
||||
|
||||
. $PSScriptRoot\post-build-utils.ps1
|
||||
|
||||
try {
|
||||
# Check that the channel we are going to promote the build to exist
|
||||
$channelInfo = Get-MaestroChannel -ChannelId $ChannelId
|
||||
|
||||
if (!$channelInfo) {
|
||||
Write-Host "Channel with BAR ID $ChannelId was not found in BAR!"
|
||||
ExitWithExitCode 1
|
||||
}
|
||||
|
||||
# Get info about which channels the build has already been promoted to
|
||||
$buildInfo = Get-MaestroBuild -BuildId $BuildId
|
||||
|
||||
if (!$buildInfo) {
|
||||
Write-Host "Build with BAR ID $BuildId was not found in BAR!"
|
||||
ExitWithExitCode 1
|
||||
}
|
||||
|
||||
# Find whether the build is already assigned to the channel or not
|
||||
if ($buildInfo.channels) {
|
||||
foreach ($channel in $buildInfo.channels) {
|
||||
if ($channel.Id -eq $ChannelId) {
|
||||
Write-Host "The build with BAR ID $BuildId is already on channel $ChannelId!"
|
||||
ExitWithExitCode 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Promoting build '$BuildId' to channel '$ChannelId'."
|
||||
|
||||
Assign-BuildToChannel -BuildId $BuildId -ChannelId $ChannelId
|
||||
|
||||
Write-Host "done."
|
||||
}
|
||||
catch {
|
||||
Write-Host "There was an error while trying to promote build '$BuildId' to channel '$ChannelId'"
|
||||
Write-Host $_
|
||||
Write-Host $_.ScriptStackTrace
|
||||
}
|
26
external/linker/eng/common/post-build/setup-maestro-vars.ps1
vendored
Normal file
26
external/linker/eng/common/post-build/setup-maestro-vars.ps1
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string] $ReleaseConfigsPath # Full path to ReleaseConfigs.txt asset
|
||||
)
|
||||
|
||||
. $PSScriptRoot\post-build-utils.ps1
|
||||
|
||||
try {
|
||||
$Content = Get-Content $ReleaseConfigsPath
|
||||
|
||||
$BarId = $Content | Select -Index 0
|
||||
|
||||
$Channels = ""
|
||||
$Content | Select -Index 1 | ForEach-Object { $Channels += "$_ ," }
|
||||
|
||||
$IsStableBuild = $Content | Select -Index 2
|
||||
|
||||
Write-PipelineSetVariable -Name 'BARBuildId' -Value $BarId
|
||||
Write-PipelineSetVariable -Name 'InitialChannels' -Value "$Channels"
|
||||
Write-PipelineSetVariable -Name 'IsStableBuild' -Value $IsStableBuild
|
||||
}
|
||||
catch {
|
||||
Write-Host $_
|
||||
Write-Host $_.Exception
|
||||
Write-Host $_.ScriptStackTrace
|
||||
ExitWithExitCode 1
|
||||
}
|
@@ -6,10 +6,7 @@ param(
|
||||
[Parameter(Mandatory=$true)][string] $SourcelinkCliVersion # Version of SourceLink CLI to use
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Set-StrictMode -Version 2.0
|
||||
|
||||
. $PSScriptRoot\..\tools.ps1
|
||||
. $PSScriptRoot\post-build-utils.ps1
|
||||
|
||||
# Cache/HashMap (File -> Exist flag) used to consult whether a file exist
|
||||
# in the repository at a specific commit point. This is populated by inserting
|
||||
@@ -200,21 +197,27 @@ function ValidateSourceLinkLinks {
|
||||
}
|
||||
}
|
||||
|
||||
function CheckExitCode ([string]$stage) {
|
||||
$exitCode = $LASTEXITCODE
|
||||
if ($exitCode -ne 0) {
|
||||
Write-PipelineTaskError "Something failed while '$stage'. Check for errors above. Exiting now..."
|
||||
ExitWithExitCode $exitCode
|
||||
function InstallSourcelinkCli {
|
||||
$sourcelinkCliPackageName = "sourcelink"
|
||||
|
||||
$dotnetRoot = InitializeDotNetCli -install:$true
|
||||
$dotnet = "$dotnetRoot\dotnet.exe"
|
||||
$toolList = & "$dotnet" tool list --global
|
||||
|
||||
if (($toolList -like "*$sourcelinkCliPackageName*") -and ($toolList -like "*$sourcelinkCliVersion*")) {
|
||||
Write-Host "SourceLink CLI version $sourcelinkCliVersion is already installed."
|
||||
}
|
||||
else {
|
||||
Write-Host "Installing SourceLink CLI version $sourcelinkCliVersion..."
|
||||
Write-Host "You may need to restart your command window if this is the first dotnet tool you have installed."
|
||||
& "$dotnet" tool install $sourcelinkCliPackageName --version $sourcelinkCliVersion --verbosity "minimal" --global
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Host "Installing SourceLink CLI..."
|
||||
Get-Location
|
||||
. $PSScriptRoot\sourcelink-cli-init.ps1 -sourcelinkCliVersion $SourcelinkCliVersion
|
||||
CheckExitCode "Running sourcelink-cli-init"
|
||||
InstallSourcelinkCli
|
||||
|
||||
Measure-Command { ValidateSourceLinkLinks }
|
||||
ValidateSourceLinkLinks
|
||||
}
|
||||
catch {
|
||||
Write-Host $_
|
||||
|
@@ -4,10 +4,7 @@ param(
|
||||
[Parameter(Mandatory=$true)][string] $DotnetSymbolVersion # Version of dotnet symbol to use
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Set-StrictMode -Version 2.0
|
||||
|
||||
. $PSScriptRoot\..\tools.ps1
|
||||
. $PSScriptRoot\post-build-utils.ps1
|
||||
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
|
||||
@@ -162,19 +159,25 @@ function CheckSymbolsAvailable {
|
||||
}
|
||||
}
|
||||
|
||||
function CheckExitCode ([string]$stage) {
|
||||
$exitCode = $LASTEXITCODE
|
||||
if ($exitCode -ne 0) {
|
||||
Write-PipelineTaskError "Something failed while '$stage'. Check for errors above. Exiting now..."
|
||||
ExitWithExitCode $exitCode
|
||||
function Installdotnetsymbol {
|
||||
$dotnetsymbolPackageName = "dotnet-symbol"
|
||||
|
||||
$dotnetRoot = InitializeDotNetCli -install:$true
|
||||
$dotnet = "$dotnetRoot\dotnet.exe"
|
||||
$toolList = & "$dotnet" tool list --global
|
||||
|
||||
if (($toolList -like "*$dotnetsymbolPackageName*") -and ($toolList -like "*$dotnetsymbolVersion*")) {
|
||||
Write-Host "dotnet-symbol version $dotnetsymbolVersion is already installed."
|
||||
}
|
||||
else {
|
||||
Write-Host "Installing dotnet-symbol version $dotnetsymbolVersion..."
|
||||
Write-Host "You may need to restart your command window if this is the first dotnet tool you have installed."
|
||||
& "$dotnet" tool install $dotnetsymbolPackageName --version $dotnetsymbolVersion --verbosity "minimal" --global
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Host "Installing dotnet symbol ..."
|
||||
Get-Location
|
||||
. $PSScriptRoot\dotnetsymbol-init.ps1 -dotnetsymbolVersion $DotnetSymbolVersion
|
||||
CheckExitCode "Running dotnetsymbol-init"
|
||||
Installdotnetsymbol
|
||||
|
||||
CheckSymbolsAvailable
|
||||
}
|
||||
|
57
external/linker/eng/common/post-build/trigger-subscriptions.ps1
vendored
Normal file
57
external/linker/eng/common/post-build/trigger-subscriptions.ps1
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string] $SourceRepo,
|
||||
[Parameter(Mandatory=$true)][int] $ChannelId,
|
||||
[Parameter(Mandatory=$true)][string] $MaestroApiAccessToken,
|
||||
[Parameter(Mandatory=$false)][string] $MaestroApiEndPoint = "https://maestro-prod.westus2.cloudapp.azure.com",
|
||||
[Parameter(Mandatory=$false)][string] $MaestroApiVersion = "2019-01-16"
|
||||
)
|
||||
|
||||
. $PSScriptRoot\post-build-utils.ps1
|
||||
|
||||
# Get all the $SourceRepo subscriptions
|
||||
$normalizedSourceRepo = $SourceRepo.Replace('dnceng@', '')
|
||||
$subscriptions = Get-MaestroSubscriptions -SourceRepository $normalizedSourceRepo -ChannelId $ChannelId
|
||||
|
||||
if (!$subscriptions) {
|
||||
Write-Host "No subscriptions found for source repo '$normalizedSourceRepo' in channel '$ChannelId'"
|
||||
ExitWithExitCode 0
|
||||
}
|
||||
|
||||
$subscriptionsToTrigger = New-Object System.Collections.Generic.List[string]
|
||||
$failedTriggeredSubscription = $false
|
||||
|
||||
# Get all enabled subscriptions that need dependency flow on 'everyBuild'
|
||||
foreach ($subscription in $subscriptions) {
|
||||
if ($subscription.enabled -and $subscription.policy.updateFrequency -like 'everyBuild' -and $subscription.channel.id -eq $ChannelId) {
|
||||
Write-Host "Should trigger this subscription: $subscription.id"
|
||||
[void]$subscriptionsToTrigger.Add($subscription.id)
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($subscriptionToTrigger in $subscriptionsToTrigger) {
|
||||
try {
|
||||
Write-Host "Triggering subscription '$subscriptionToTrigger'."
|
||||
|
||||
Trigger-Subscription -SubscriptionId $subscriptionToTrigger
|
||||
|
||||
Write-Host "done."
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host "There was an error while triggering subscription '$subscriptionToTrigger'"
|
||||
Write-Host $_
|
||||
Write-Host $_.ScriptStackTrace
|
||||
$failedTriggeredSubscription = $true
|
||||
}
|
||||
}
|
||||
|
||||
if ($subscriptionsToTrigger.Count -eq 0) {
|
||||
Write-Host "No subscription matched source repo '$normalizedSourceRepo' and channel ID '$ChannelId'."
|
||||
}
|
||||
elseif ($failedTriggeredSubscription) {
|
||||
Write-Host "At least one subscription failed to be triggered..."
|
||||
ExitWithExitCode 1
|
||||
}
|
||||
else {
|
||||
Write-Host "All subscriptions were triggered successfully!"
|
||||
}
|
Reference in New Issue
Block a user