Skip to content

Commit

Permalink
[ci] Add job to run after Xamarin.Android pipeline (dotnet#6881)
Browse files Browse the repository at this point in the history
Context: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/pipeline-triggers

A new pipeline has been added to capture build information from the
Xamarin.Android pipeline, which can than be processed by our older
UI-style release definitions.

The Xamarin.Android pipeline often has known or acceptable test
failures in the builds that we want to release, and old UI-style
release definitions will not run against partially failed builds.
This new pipeline avoids that limitation as it will always be green.
The new pipeline will also publish information about the
Xamarin.Android build that triggered it, which will allow an old
UI-style release definition to download artifacts from the
Xamarin.Android build using the [DownloadPipelineArtifact][1] task.

A [pipeline resource][0] controls the automatic triggering of this
new pipeline, and it will run once the `post_build` stage in the
Xamarin.Android pipeline completes successfully.

The classic VS insertions will look like this:

 1. A `Xamarin.Android` pipeline build finishes.

 2. A new build of `Xamarin.Android Release Trigger` will run
    automatically.

 3. This pipeline publishes a file containing `Xamarin.Android` build
    and pipeline ID information.

 4. The `Xamarin.Android - VS + VSM Release Insertion` release
    definition uses the build and pipeline ID to download the SBOM
    artifact in the corresponding `Xamarin.Android` build.

This new pipeline can also be used to "transfer" other build
artifacts from the `Xamarin.Android` pipeline to other release
definitions in the future if needed.

[0]: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/resources?view=azure-devops&tabs=schema#define-a-pipelines-resource
[1]: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/download-pipeline-artifact?view=azure-devops#arguments
  • Loading branch information
pjcollins authored and jonpryor committed May 23, 2022
1 parent 3139724 commit b6fe6eb
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions build-tools/automation/azure-pipelines-release-trigger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Xamarin.Android Release Definition Trigger

name: $(Build.SourceBranchName)-$(Build.SourceVersion)-$(Rev:r)

trigger: none
pr: none

resources:
pipelines:
- pipeline: xamarin-android
source: Xamarin.Android
trigger:
stages:
- post_build

jobs:
- job: release_trigger
displayName: Upload Info from Triggering Build
timeoutInMinutes: 30
pool: VSEngSS-MicroBuild2022-1ES
workspace:
clean: all
steps:
- checkout: none

- powershell: |
$triggeringBuild = @{
"triggeringBuild" = @{
"id" = "$(Build.TriggeredBy.BuildId)"
"pipeline" = "$(Build.TriggeredBy.DefinitionId)"
"project" = "$(Build.TriggeredBy.ProjectID)"
}
}
$json = $triggeringBuild | ConvertTo-Json
New-Item -Path $(Build.StagingDirectory) -Name triggering-build.json -ItemType file -Value $json -Force
$jsonContent = Get-Content "$(Build.StagingDirectory)\triggering-build.json" | ConvertFrom-Json
Write-Host Triggering Build Info: $jsonContent.triggeringBuild.project - $jsonContent.triggeringBuild.pipeline - $jsonContent.triggeringBuild.id
displayName: write triggering-build.json
- task: PublishPipelineArtifact@1
displayName: upload triggering-build-info
inputs:
artifactName: triggering-build-info
targetPath: $(Build.StagingDirectory)\triggering-build.json

0 comments on commit b6fe6eb

Please sign in to comment.