Skip to content

Commit 9c64bcb

Browse files
authored
Merge pull request #90 from buildkite-plugins/SUP-1358-FixRecursiveZip
Sup 1358 fix recursive zip
2 parents 5b97e43 + 9546000 commit 9c64bcb

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,29 +134,30 @@ The build UUID to download the artifact from unless specificed otherwise in the
134134

135135
### `compressed` (optional, string)
136136

137-
Limitations:
137+
⚠️ Limitations:
138138
* filename needs to end with `.zip` or `.tgz` and that will determine the compression executable to use
139-
* path globs (`*`) are interpreted by agent's shell and (un)compressing program (meaning that probably `**` will not work)
139+
* path globs (`*`) are interpreted by agent's shell and (un)compressing program, meaning that `*` and `**` will not work.
140+
141+
When uploading, the file or directory specified in the `upload` option will be compressed in a single file with this name and uploaded as a single artifact. The following example will get the directory matching `log/my-folder`, zip them up and upload a single artifact file named `logs.zip`:
140142

141-
When uploading, globs specified in the `upload` option will be compressed in a single file with this name and uploaded as a single artifact. The following example will get all files matching `log/*.log`, zip them up and upload a single artifact file named `logs.zip`:
142143

143144
```yml
144145
steps:
145146
- command: ...
146147
plugins:
147148
- artifacts#v1.9.0:
148-
upload: "log/*.log"
149+
upload: "log/my-folder"
149150
compressed: logs.zip
150151
```
151152

152-
When downloading, this option states the actual name of the artifact to be downloaded and globs in the `download` option will be extracted off of it. The following example will download the `logs.tgz` artifact and extract all files in it matching `log/*.log`:
153+
When downloading, this option states the actual name of the artifact to be downloaded in the `download` option will be extracted off of it. The following example will download the `logs.tgz` artifact and extract all files in it matching `log/file.log`:
153154

154155
```yml
155156
steps:
156157
- command: ...
157158
plugins:
158159
- artifacts#v1.9.0:
159-
download: "log/*.log"
160+
download: "log/file.log"
160161
compressed: logs.tgz
161162
```
162163

hooks/post-command

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ if [[ -n "${BUILDKITE_PLUGIN_ARTIFACTS_COMPRESSED:-}" ]]; then
5555
COMPRESSED="true"
5656

5757
if [[ "${BUILDKITE_PLUGIN_ARTIFACTS_COMPRESSED}" =~ .*\.zip ]]; then
58-
compress+=("zip" "${BUILDKITE_PLUGIN_ARTIFACTS_COMPRESSED}")
58+
compress+=("zip" "-r" "${BUILDKITE_PLUGIN_ARTIFACTS_COMPRESSED}")
5959
elif [[ "${BUILDKITE_PLUGIN_ARTIFACTS_COMPRESSED}" =~ .*\.tgz ]]; then
6060
compress+=("tar" "czf" "${BUILDKITE_PLUGIN_ARTIFACTS_COMPRESSED}")
6161
else

tests/upload-compressed.bats

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ load "${BATS_PLUGIN_PATH}/load.bash"
2727
"artifact upload \* : echo uploaded \$3"
2828

2929
stub zip \
30-
"\* \* : echo zipped \$2 into \$1"
30+
"-r \* \* : echo zipped \$3 into \$2"
3131

3232
run "$PWD/hooks/post-command"
3333

@@ -76,7 +76,7 @@ load "${BATS_PLUGIN_PATH}/load.bash"
7676
"artifact upload \* : echo uploaded \$3"
7777

7878
stub zip \
79-
"\* \* : echo zipped \$2 into \$1"
79+
"-r \* \* : echo zipped \$3 into \$2"
8080

8181
touch /tmp/foo.log
8282

@@ -146,7 +146,7 @@ load "${BATS_PLUGIN_PATH}/load.bash"
146146
"artifact upload --job \* \* : echo uploaded \$5 with --job \$4"
147147

148148
stub zip \
149-
"\* \* : echo zipped \$2 into \$1"
149+
"-r \* \* : echo zipped \$3 into \$2"
150150

151151
run "$PWD/hooks/post-command"
152152

@@ -201,7 +201,7 @@ load "${BATS_PLUGIN_PATH}/load.bash"
201201
"artifact upload \* : echo uploaded \$3"
202202

203203
stub zip \
204-
"\* \* \* \* : echo zipped \$2, \$3 and \$4 into \$1"
204+
"-r \* \* \* \* : echo zipped \$3, \$4 and \$5 into \$2"
205205

206206
run "$PWD/hooks/post-command"
207207

@@ -266,7 +266,7 @@ load "${BATS_PLUGIN_PATH}/load.bash"
266266
"artifact upload \* : echo uploaded \$3"
267267

268268
stub zip \
269-
"\* \* \* \* : echo zipped \$2, \$3 and \$4 into \$1"
269+
"-r \* \* \* \* : echo zipped \$3, \$4 and \$5 into \$2"
270270

271271
run "$PWD/hooks/post-command"
272272

@@ -365,4 +365,4 @@ load "${BATS_PLUGIN_PATH}/load.bash"
365365
unset BUILDKITE_PLUGIN_ARTIFACTS_DOWNLOAD_0_FROM
366366
unset BUILDKITE_PLUGIN_ARTIFACTS_DOWNLOAD_0_TO
367367
unset BUILDKITE_PLUGIN_ARTIFACTS_COMPRESSED
368-
}
368+
}

0 commit comments

Comments
 (0)