Skip to content

Commit

Permalink
[CI] Allow the postbuild pipelines to download the needed artifacts f…
Browse files Browse the repository at this point in the history
…or the tests. (#20588)

This change allows the post build pipelines to download the artefacts generated by the build pipeline that triggered them. This way we can split builds from tests.
  • Loading branch information
mandel-macaque committed May 15, 2024
1 parent 9b64421 commit cfcdacd
Showing 1 changed file with 65 additions and 29 deletions.
94 changes: 65 additions & 29 deletions tools/devops/automation/templates/tests/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,45 +145,81 @@ steps:
AUTH_TOKEN_VSENG_XAMARIN_MAC_DEVICES_P12: ${{ parameters.xqaCertPass }}
AUTH_TOKEN_VSENG_XAMARIN_MAC_DEVICES_2_P12: ${{ parameters.xqaCertPass }}

# this could be a template, which would make everything a lot simpler BUT alas we found a bug in Azure Devops (bugs++).
# if we use a template here azure devops will throw an exception due to a foreign key constraint error in their PK_Task_tbl_PlanContext.
# The simplest way to workaround their bad code is to remove the template and that way there wont be a task issue. I suspect that
# the problem resides in the fact that this is a template within a template within a matrix.
- bash: |
sudo rm -Rf $(Build.SourcesDirectory)/artifacts
displayName: "Remove artifacts"
condition: always()

- task: DownloadPipelineArtifact@2
displayName: Download PkgsVersions.json
inputs:
allowFailedBuilds: true
patterns: '**/PkgsVersions.json'
path: $(Build.SourcesDirectory)/artifacts

- task: DownloadPipelineArtifact@2
displayName: Download WorkloadRollback.json
inputs:
allowFailedBuilds: true
patterns: '**/WorkloadRollback.json'
path: $(Build.SourcesDirectory)/artifacts

- task: DownloadPipelineArtifact@2
displayName: Download packages
inputs:
allowFailedBuilds: true
artifactName: not-signed-package
path: $(Build.SourcesDirectory)/artifacts/not-signed-package

- task: DownloadPipelineArtifact@2
displayName: Download test libraries
inputs:
allowFailedBuilds: true
artifactName: package-test-libraries
path: $(Build.SourcesDirectory)/artifacts/package-test-libraries

# use a diff step depending if we have been trigger by a pipeline of by a PR/Commit
- ${{ if or(contains(variables['Build.Reason'], 'ResourceTrigger'), contains(variables['Build.Reason'], 'BuildCompletion')) }}:
- download: macios
displayName: Download PkgsVersions.json
artifact: PkgsVersions

- download: macios
displayName: Download WorkloadRollback.json
artifact: WorkloadRollback

- download: macios
displayName: Download packages
artifact: not-signed-package

- download: macios
displayName: Download test libraries
artifact: package-test-libraries

- pwsh: |
Get-ChildItem -Path "$(Pipeline.Workspace)/macios" -Recurse -Force
displayName: 'Display downloads'
timeoutInMinutes: 5
# the default location when downloading is $(Pipeline.Workspace)/<pipeline resource identifier>/<artifact name>
- bash: |
source="$PIPELINE_WORKSPACE/macios"
destination="$BUILD_SOURCESDIRECTORY/artifacts"
# move all the files from the source to the destination
mv -fv "$source" "$destination"
displayName: Move artifacts to the expected location
- ${{ else }}:
- task: DownloadPipelineArtifact@2
displayName: Download PkgsVersions.json
inputs:
allowFailedBuilds: true
patterns: '**/PkgsVersions.json'
path: $(Build.SourcesDirectory)/artifacts

- task: DownloadPipelineArtifact@2
displayName: Download WorkloadRollback.json
inputs:
allowFailedBuilds: true
patterns: '**/WorkloadRollback.json'
path: $(Build.SourcesDirectory)/artifacts

- task: DownloadPipelineArtifact@2
displayName: Download packages
inputs:
allowFailedBuilds: true
artifactName: not-signed-package
path: $(Build.SourcesDirectory)/artifacts/not-signed-package

- task: DownloadPipelineArtifact@2
displayName: Download test libraries
inputs:
allowFailedBuilds: true
artifactName: package-test-libraries
path: $(Build.SourcesDirectory)/artifacts/package-test-libraries

# print the downloads to make our life easier on debug
- pwsh: |
Get-ChildItem -Path $(Build.SourcesDirectory)/artifacts -Recurse -Force
displayName: 'Display downloads'
timeoutInMinutes: 5


- pwsh: |
$dir = "$(Build.SourcesDirectory)/artifacts"
$versionsPath = "$dir/${{ parameters.uploadPrefix }}PkgsVersions/PkgsVersions.json"
Expand Down

12 comments on commit cfcdacd

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.