From df6560ff9cad38905303616f4c7369aa5c0ba465 Mon Sep 17 00:00:00 2001 From: Gregory Haddow <93638800+ankorstore-haddowg@users.noreply.github.com> Date: Fri, 12 May 2023 11:07:51 +0100 Subject: [PATCH] Fix/artifact compression (#41) * fix: store_compressed_artifacts should store tar in path by default, allow optionally specifying a destination * fix: get-job-artifacts should remove unzipped tarballs * chore: output artifact pattern in get-job-artifacts --- src/commands/store_compressed_artifacts.yml | 23 +++++++++++++++++---- src/scripts/get-job-artifacts.sh | 3 ++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/commands/store_compressed_artifacts.yml b/src/commands/store_compressed_artifacts.yml index b80fd0f..8edc54f 100644 --- a/src/commands/store_compressed_artifacts.yml +++ b/src/commands/store_compressed_artifacts.yml @@ -9,6 +9,10 @@ parameters: path: type: string description: Path to file or directory to store + destination: + type: string + description: Destination directory to store the tarball, defaults to the path but should be provided if the path is a file. + default: "" steps: - run: name: Compressing << parameters.tarball-name >> @@ -16,7 +20,18 @@ steps: TARBALL_NAME: << parameters.tarball-name >> ARTIFACT_PATH: << parameters.path >> command: << include(scripts/store_compressed_artifacts.sh) >> - - store_artifacts: - name: Store << parameters.tarball-name >> - path: /tmp/<< parameters.tarball-name >> - destination: "" + - when: + condition: << parameters.destination >> + steps: + - store_artifacts: + name: Store << parameters.tarball-name >> + path: << parameters.tarball-name >> + destination: << parameters.destination >> + - when: + condition: + not: << parameters.destination >> + steps: + - store_artifacts: + name: Store << parameters.tarball-name >> + path: << parameters.tarball-name >> + destination: << parameters.path >> diff --git a/src/scripts/get-job-artifacts.sh b/src/scripts/get-job-artifacts.sh index 4b88622..b269e6e 100755 --- a/src/scripts/get-job-artifacts.sh +++ b/src/scripts/get-job-artifacts.sh @@ -104,6 +104,7 @@ get_artifacts_for_job() { echo "Unzipping files:" cat "$tmp_zipped" xargs -n 1 tar -xzf < "$tmp_zipped" + xargs -n 1 rm < "$tmp_zipped" fi } @@ -114,7 +115,7 @@ else TARGET_PATH="$CIRCLE_WORKING_DIRECTORY" fi -echo "Downloading artifact(s) from job(s): $JOB_LIST" +echo "Downloading artifact(s) matching \`$TARGET_ARTIFACT_PATTERN\` from job(s): $JOB_LIST" echo "Downloading artifact(s) to $TARGET_PATH" get_jobs_in_workflow for JOB_NAME in ${JOB_LIST//,/ }