Miguel Young de la Sota | b4df860 | 2019-11-21 12:44:11 -0600 | [diff] [blame] | 1 | # Copyright lowRISC contributors. |
| 2 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | |
| 5 | # Azure template for archiving pipeline step outputs and uploading them. |
| 6 | # |
| 7 | # This template will archive all of $BIN_DIR, and upload it for use by |
Philipp Wagner | 5aa7ed3 | 2021-02-02 18:53:36 +0000 | [diff] [blame] | 8 | # downstream jobs using download-artifacts-template.yml. |
Miguel Young de la Sota | b4df860 | 2019-11-21 12:44:11 -0600 | [diff] [blame] | 9 | # |
| 10 | # This template expects that a variable $BUILD_ROOT is set. See |
| 11 | # util/build_consts.sh for more information. |
| 12 | |
Philipp Wagner | 5aa7ed3 | 2021-02-02 18:53:36 +0000 | [diff] [blame] | 13 | |
| 14 | parameters: |
| 15 | # Rsync-style file patterns to include in the partial BIN_DIR output. |
| 16 | - name: includePatterns |
| 17 | type: object |
| 18 | default: [] |
| 19 | |
Miguel Young de la Sota | b4df860 | 2019-11-21 12:44:11 -0600 | [diff] [blame] | 20 | steps: |
| 21 | - bash: | |
| 22 | set -e |
| 23 | test -n "$BUILD_ROOT" |
| 24 | . util/build_consts.sh |
| 25 | |
Philipp Wagner | 5aa7ed3 | 2021-02-02 18:53:36 +0000 | [diff] [blame] | 26 | # Write all include patterns to a file used by rsync. |
| 27 | echo "${{ join('\n', parameters.includePatterns) }}" > "$BUILD_ROOT/include_patterns.txt" |
| 28 | |
| 29 | echo |
| 30 | echo Files matching these patterns will be included in the binary build artifact for this job: |
| 31 | echo vvvvvvvvvvvvvvvvvv |
| 32 | cat "$BUILD_ROOT/include_patterns.txt" |
| 33 | echo ^^^^^^^^^^^^^^^^^^ |
| 34 | |
| 35 | # The file upstream_bin_dir_contents.txt lists all files which were part |
| 36 | # of an "upstream" BIN_DIR which got downloaded at the beginning of this |
| 37 | # job. Ensure that this file exists, even if no upstream BIN_DIR was |
| 38 | # downloaded. |
| 39 | touch "$BUILD_ROOT/upstream_bin_dir_contents.txt" |
| 40 | |
| 41 | BIN_DIR_FULL="${BIN_DIR}.full" |
| 42 | mv "$BIN_DIR" "$BIN_DIR_FULL" |
| 43 | mkdir -p "$BIN_DIR" |
| 44 | |
| 45 | echo |
| 46 | echo Copying files into the output archive: |
| 47 | rsync \ |
| 48 | --archive \ |
| 49 | --verbose \ |
| 50 | --remove-source-files \ |
| 51 | --prune-empty-dirs \ |
| 52 | --exclude-from="$BUILD_ROOT/upstream_bin_dir_contents.txt" \ |
| 53 | --include="*/" \ |
| 54 | --include-from="$BUILD_ROOT/include_patterns.txt" \ |
| 55 | --exclude="*" \ |
| 56 | "${BIN_DIR_FULL}/" "${BIN_DIR}/" |
| 57 | |
| 58 | echo |
| 59 | echo 'Files in $BIN_DIR not considered outputs of this job:' |
| 60 | echo vvvvvvvvvvvvvvvvvv |
| 61 | find "$BIN_DIR_FULL" |
| 62 | echo ^^^^^^^^^^^^^^^^^^ |
| 63 | |
Miguel Young de la Sota | b4df860 | 2019-11-21 12:44:11 -0600 | [diff] [blame] | 64 | tar -C "$BUILD_ROOT" \ |
| 65 | -cvf "$BUILD_ROOT/build-bin.tar" \ |
| 66 | "${BIN_DIR#"$BUILD_ROOT/"}" |
Philipp Wagner | 5aa7ed3 | 2021-02-02 18:53:36 +0000 | [diff] [blame] | 67 | displayName: Archive step outputs |
Miguel Young de la Sota | b4df860 | 2019-11-21 12:44:11 -0600 | [diff] [blame] | 68 | - publish: "$(Build.ArtifactStagingDirectory)/build-bin.tar" |
Philipp Wagner | 5aa7ed3 | 2021-02-02 18:53:36 +0000 | [diff] [blame] | 69 | # The PhaseName is the string after the "job" key in the build description, |
| 70 | # e.g. "job: my_phase_name". |
| 71 | artifact: partial-build-bin-$(System.PhaseName) |
| 72 | displayName: Upload step outputs |