|
| 1 | +parameters: |
| 2 | + gatherJobs: [] |
| 3 | + gatherPortableJob: '' |
| 4 | + |
| 5 | + # downloadBuildConfig by default uses the current build, but can be changed to point at an |
| 6 | + # existing/previous build by passing properties like these, instead: |
| 7 | + # |
| 8 | + # buildType: specific |
| 9 | + # buildVersionToDownload: specific |
| 10 | + # project: 'public' |
| 11 | + # definition: 'source-build-CI' |
| 12 | + # buildId: 741400 |
| 13 | + # |
| 14 | + # By defining this in one place, it's easier to set this up if necessary. This may be useful |
| 15 | + # because the build takes a long time relative to prepare-artifacts, and we may want to tweak |
| 16 | + # prepare-artifacts in case it fails due to a bug in the future. ...It's also nice to have the |
| 17 | + # properties listed in this comment even if we don't use them here, because it's hard to figure |
| 18 | + # them out from the docs alone--it'll be a nice reference. |
| 19 | + downloadBuildConfig: |
| 20 | + buildType: current |
| 21 | + |
| 22 | +stages: |
| 23 | +- stage: PrepareArtifacts |
| 24 | + dependsOn: |
| 25 | + - ${{ each gather in parameters.gatherJobs }}: |
| 26 | + - ${{ gather.job }} |
| 27 | + jobs: |
| 28 | + - job: PrepareArtifacts |
| 29 | + pool: |
| 30 | + vmImage: 'ubuntu-18.04' |
| 31 | + timeoutInMinutes: 300 |
| 32 | + workspace: |
| 33 | + clean: all |
| 34 | + variables: |
| 35 | + artifactStageDir: '$(Build.SourcesDirectory)/artifacts/stage' |
| 36 | + nonportableSourceBuiltStageDir: '$(artifactStageDir)/nonportableSourceBuilt' |
| 37 | + portableSourceBuiltStageDir: '$(artifactStageDir)/portableSourceBuilt' |
| 38 | + allSourceBuiltStageDir: '$(artifactStageDir)/allSourceBuilt' |
| 39 | + outputTarballFile: '$(artifactStageDir)/Private.SourceBuilt.Artifacts.$(Build.BuildId).tar.gz' |
| 40 | + steps: |
| 41 | + - ${{ each gather in parameters.gatherJobs }}: |
| 42 | + - task: DownloadBuildArtifacts@0 |
| 43 | + displayName: 'Download ${{ gather.job }} nonportable' |
| 44 | + inputs: |
| 45 | + ${{ insert }}: ${{ parameters.downloadBuildConfig }} |
| 46 | + downloadType: single |
| 47 | + artifactName: ${{ coalesce(gather.artifactName, format('Tarball {0}', gather.job)) }} |
| 48 | + downloadPath: $(nonportableSourceBuiltStageDir) |
| 49 | + allowPartiallySucceededBuilds: true |
| 50 | + |
| 51 | + - task: DownloadBuildArtifacts@0 |
| 52 | + displayName: 'Download ${{ parameters.gatherPortableJob }} portable' |
| 53 | + inputs: |
| 54 | + ${{ insert }}: ${{ parameters.downloadBuildConfig }} |
| 55 | + downloadType: single |
| 56 | + artifactName: 'Tarball ${{ parameters.gatherPortableJob }}' |
| 57 | + downloadPath: $(portableSourceBuiltStageDir) |
| 58 | + allowPartiallySucceededBuilds: true |
| 59 | + |
| 60 | + - script: | |
| 61 | + find "$(artifactStageDir)" -type f -exec du -h {} \; |
| 62 | + displayName: Show downloaded artifacts |
| 63 | +
|
| 64 | + - script: | |
| 65 | + set -xeuo pipefail |
| 66 | + mkdir -p "$(allSourceBuiltStageDir)" |
| 67 | +
|
| 68 | + # Extract all source-built assets into a single place. Overlap and overwrites are expected. |
| 69 | + # What matters is the portable ones are copied last and ultimately win. |
| 70 | + find \ |
| 71 | + "$(nonportableSourceBuiltStageDir)" \ |
| 72 | + "$(portableSourceBuiltStageDir)" \ |
| 73 | + -iname 'Private.SourceBuilt.Artifacts.*.tar.gz' \ |
| 74 | + -exec tar -xf {} -C "$(allSourceBuiltStageDir)" \; |
| 75 | +
|
| 76 | + # Intentionally don't create a top-level directory. Matches earlier versions of this artifact. |
| 77 | + cd "$(allSourceBuiltStageDir)" |
| 78 | + tar --numeric-owner -czf "$(outputTarballFile)" * |
| 79 | + displayName: Create source-built artifacts tar.gz |
| 80 | +
|
| 81 | + - publish: '$(outputTarballFile)' |
| 82 | + artifact: Private.SourceBuilt.Artifacts |
| 83 | + |
| 84 | + - script: | |
| 85 | + tar -tf "$(outputTarballFile)" | sort |
| 86 | + displayName: Show tarball contents |
0 commit comments