Update eng/common folder (#861)
This commit is contained in:
Родитель
d83bdba7bc
Коммит
3aeae1f874
|
@ -156,10 +156,9 @@ jobs:
|
|||
- ${{ if eq(parameters.publishToMaestro, 'true') }}:
|
||||
- template: ..\..\eng\common\Maestro-PublishBuildToMaestro.yml
|
||||
parameters:
|
||||
IsGitHubRepo: true
|
||||
AssetName: 'Microsoft.ProjectReunion.Foundation.TransportPackage'
|
||||
AssetVersion: $(packageVersion)
|
||||
TriggerSubscrption: true
|
||||
TriggerSubscription: true
|
||||
#UNDONE - EHO we need to seed these guid's properly!
|
||||
#see, e.g. AzurePipelinesTemplates\ProjectReunion-BuildAndPublishPGONuGet-Job.yml
|
||||
#
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
parameters:
|
||||
AssetName: ''
|
||||
AssetVersion: ''
|
||||
TriggerSubscrption: false
|
||||
IsGitHubRepo: true
|
||||
TriggerSubscription: false
|
||||
|
||||
steps:
|
||||
- task: PowerShell@2
|
||||
|
@ -60,18 +59,9 @@ steps:
|
|||
$devOpsAccount = ExtractOrgFromAzureDevOpsCollectionUri '$(System.CollectionUri)'
|
||||
Write-Host "reposiitory: $(Build.Repository.Uri)"
|
||||
Write-Host "account: " $devOpsAccount
|
||||
|
||||
$gitHubRepo = ""
|
||||
$azureDevOpsRepo = ""
|
||||
if ('${{ parameters.IsGitHubRepo }}' -eq 'true')
|
||||
{
|
||||
$gitHubRepo = "$(Build.Repository.Uri)"
|
||||
$azureDevOpsRepo = "$(Build.Repository.Uri)" # Maestro expects this to be always set
|
||||
}
|
||||
if ('${{ parameters.IsGitHubRepo }}' -ne 'true')
|
||||
{
|
||||
$azureDevOpsRepo = "$(Build.Repository.Uri)"
|
||||
}
|
||||
|
||||
$gitHubRepo = "$(Build.Repository.Uri)"
|
||||
$azureDevOpsRepo = "$(Build.Repository.Uri)"
|
||||
|
||||
$jsonBase =
|
||||
@{
|
||||
|
@ -103,15 +93,27 @@ steps:
|
|||
filePath: eng\common\MaestroPostRequest.ps1
|
||||
arguments: -url '$(MaestroUri)' -Token '$(MaestroToken)' -api '/api/builds' -jsonBodyPath '$(Build.SourcesDirectory)\eng\common\maestro-build.json'
|
||||
|
||||
- ${{ if eq(parameters.TriggerSubscrption, 'true') }}:
|
||||
- ${{ if eq(parameters.TriggerSubscription, 'true') }}:
|
||||
- task: powershell@2
|
||||
displayName: 'Publish Build to Default Channel'
|
||||
inputs:
|
||||
targetType: 'inline'
|
||||
script: |
|
||||
. .\eng\common\MaestroHelpers.ps1
|
||||
|
||||
$repository = '$(Build.Repository.Uri)'
|
||||
if (!(IsGitHubRepo($repository)))
|
||||
{
|
||||
# Maestro expects https://dev.azure.com/microsoft/xx/_git/xx
|
||||
# But Build.Repository.Uri returns https://microsoft.visualstudio.com/xx/_git/xx
|
||||
# So we convert it into the right form here
|
||||
$repository = ConvertToMaestroFriendlyUri $repository
|
||||
}
|
||||
|
||||
# Get the id of the default channel of this branch
|
||||
$api = "/api/default-channels"
|
||||
$response = &".\eng\common\MaestroGetRequest.ps1" -url '$(MaestroUri)' -Token '$(MaestroToken)' -api $api -queryParameters '&repository=$(Build.Repository.Uri)&branch=$(Build.SourceBranch)'
|
||||
$queryParam = "&repository=" + $repository + "&branch=$(Build.SourceBranch)"
|
||||
$response = &".\eng\common\MaestroGetRequest.ps1" -url '$(MaestroUri)' -Token '$(MaestroToken)' -api $api -queryParameters $queryParam
|
||||
$jsonObj = ConvertFrom-Json $response.Content
|
||||
$channelId = $jsonObj.channel.id
|
||||
if ([string]::IsNullOrEmpty($channelId))
|
||||
|
@ -123,7 +125,8 @@ steps:
|
|||
{
|
||||
# Get the id of the build posted earlier
|
||||
$api = "/api/builds"
|
||||
$response = &".\eng\common\MaestroGetRequest.ps1" -url '$(MaestroUri)' -Token '$(MaestroToken)' -api $api -queryParameters '&repository=$(Build.Repository.Uri)&commit=$(Build.SourceVersion)'
|
||||
$queryParam = "&repository=" + $repository + "&commit=$(Build.SourceVersion)"
|
||||
$response = &".\eng\common\MaestroGetRequest.ps1" -url '$(MaestroUri)' -Token '$(MaestroToken)' -api $api -queryParameters $queryParam
|
||||
$jsonObj = ConvertFrom-Json $response.Content
|
||||
$buildId = $jsonObj.id
|
||||
if ([string]::IsNullOrEmpty($buildId))
|
||||
|
@ -134,6 +137,8 @@ steps:
|
|||
|
||||
# AddBuildToChannel with the corresponding build id and channel id
|
||||
$api = "/api/channels/" + $channelId + "/builds/" + $buildId
|
||||
# buildId may return a space separated numbers if there are more than one build for the same commit
|
||||
$api = $api.Split(" ")[0]
|
||||
$response = &".\eng\common\MaestroPostRequest.ps1" -url '$(MaestroUri)' -Token '$(MaestroToken)' -api $api -jsonBodyPath ''
|
||||
|
||||
# Get the list of subscriptions on the channel
|
||||
|
@ -143,12 +148,15 @@ steps:
|
|||
$jsonObj = ConvertFrom-Json $response.Content
|
||||
foreach ($sub in $jsonObj)
|
||||
{
|
||||
# Trigger the subscription
|
||||
$id = $sub.id
|
||||
Write-Host "Triggering subscription on " $id
|
||||
# bar-build-id is always 0
|
||||
$api = "/api/subscriptions/" + $id + "/trigger"
|
||||
$response = &".\eng\common\MaestroPostRequest.ps1" -url '$(MaestroUri)' -Token '$(MaestroToken)' -api $api -jsonBodyPath '' -queryParameters '&bar-build-id=0'
|
||||
if ($sub.sourceRepository -eq $repository)
|
||||
{
|
||||
# Trigger the subscription
|
||||
$id = $sub.id
|
||||
Write-Host "Triggering subscription on " $id
|
||||
# bar-build-id is always 0
|
||||
$api = "/api/subscriptions/" + $id + "/trigger"
|
||||
$response = &".\eng\common\MaestroPostRequest.ps1" -url '$(MaestroUri)' -Token '$(MaestroToken)' -api $api -jsonBodyPath '' -queryParameters '&bar-build-id=0'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,4 +6,25 @@ function ExtractOrgFromAzureDevOpsCollectionUri([string]$CollectionUri)
|
|||
$temp1 = $Split1[0]
|
||||
$Split2 = $temp1.Substring(8)
|
||||
return $Split2
|
||||
}
|
||||
|
||||
function ConvertToMaestroFriendlyUri([string]$buildRepositoryUri)
|
||||
{
|
||||
$devOpsAccount = ExtractOrgFromAzureDevOpsCollectionUri $buildRepositoryUri
|
||||
$buildRepositoryUriSplit = $buildRepositoryUri.Split("/")
|
||||
$repository = "https://dev.azure.com/" + $devOpsAccount + "/" + $buildRepositoryUriSplit[3] + "/" + $buildRepositoryUriSplit[4] + "/" + $buildRepositoryUriSplit[5]
|
||||
return $repository
|
||||
}
|
||||
|
||||
function IsGitHubRepo([string]$buildRepositoryUri)
|
||||
{
|
||||
$githubUri = "https://github.com"
|
||||
if ($buildRepositoryUri.length -ge $githubUri.length)
|
||||
{
|
||||
if($buildRepositoryUri.Substring(0, $githubUri.length) -eq $githubUri)
|
||||
{
|
||||
return $true
|
||||
}
|
||||
}
|
||||
return $false
|
||||
}
|
Загрузка…
Ссылка в новой задаче