Skip to content

Commit 9ecba0a

Browse files
authored
Merge pull request #480 from buildkite-plugins/toote_quiet_push
Quiet push
2 parents 315b224 + bed1407 commit 9ecba0a

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,15 @@ Sets `docker-compose` to run with `--verbose`
273273

274274
The default is `false`.
275275

276-
#### `quiet-pull` (run only, boolean)
276+
#### `quiet-pull` (run/push only, boolean)
277277

278-
Start up dependencies with `--quiet-pull` to prevent even more logs during that portion of the execution.
278+
During `run`, start up dependencies with `--quiet-pull` to prevent even more logs during that portion of the execution. Will also add `--quiet` if a `docker pull` is executed before a `push` step.
279+
280+
The default is `false`.
281+
282+
#### `quiet-push` (push only, boolean)
283+
284+
Will add `--quiet` to the `docker push` command to prevent such verbose logs.
279285

280286
The default is `false`.
281287

commands/push.sh

+13-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ fi
2121

2222
pulled_services=("")
2323
build_services=("")
24+
push_command=(push)
25+
pull_command=(pull)
26+
27+
if [ "$(plugin_read_config QUIET_PUSH 'false')" == "true" ]; then
28+
push_command+=("--quiet")
29+
fi
30+
31+
if [ "$(plugin_read_config QUIET_PULL "false")" == "true" ] ; then
32+
pull_command+=("--quiet")
33+
fi
2434

2535
if plugin_read_list_into_result BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILD; then
2636
build_services=("${result[@]}")
@@ -45,7 +55,7 @@ for line in $(plugin_read_list PUSH) ; do
4555
# Only pull it down once
4656
if ! in_array "${service_name}" "${pulled_services[@]}" ; then
4757
echo "~~~ :docker: Pulling pre-built service ${service_name}" >&2;
48-
retry "$push_retries" plugin_prompt_and_run docker pull "$prebuilt_image"
58+
retry "$push_retries" plugin_prompt_and_run docker "${pull_command[@]}" "$prebuilt_image"
4959
pulled_services+=("${service_name}")
5060
fi
5161

@@ -64,15 +74,15 @@ for line in $(plugin_read_list PUSH) ; do
6474
# push: "service-name"
6575
if [[ ${#tokens[@]} -eq 1 ]] ; then
6676
echo "${group_type} :docker: Pushing images for ${service_name}" >&2;
67-
retry "$push_retries" run_docker_compose push "${service_name}"
77+
retry "$push_retries" run_docker_compose "${push_command[@]}" "${service_name}"
6878
set_prebuilt_image "${prebuilt_image_namespace}" "${service_name}" "${service_image}"
6979
target_image="${service_image}" # necessary for build-alias
7080
# push: "service-name:repo:tag"
7181
else
7282
target_image="$(IFS=:; echo "${tokens[*]:1}")"
7383
echo "${group_type} :docker: Pushing image $target_image" >&2;
7484
plugin_prompt_and_run docker tag "$service_image" "$target_image"
75-
retry "$push_retries" plugin_prompt_and_run docker push "$target_image"
85+
retry "$push_retries" plugin_prompt_and_run docker "${push_command[@]}" "$target_image"
7686
set_prebuilt_image "${prebuilt_image_namespace}" "${service_name}" "${target_image}"
7787
fi
7888
done

commands/run.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,21 @@ if [[ ${#prebuilt_services[@]} -gt 0 ]] ; then
7171
up_params+=(-f "$override_file")
7272
fi
7373

74+
pull_params+=("pull")
75+
7476
# If there are multiple services to pull, run it in parallel (although this is now the default)
7577
if [[ ${#pull_services[@]} -gt 1 ]] ; then
76-
pull_params+=("pull" "--parallel" "${pull_services[@]}")
77-
elif [[ ${#pull_services[@]} -eq 1 ]] ; then
78-
pull_params+=("pull" "${pull_services[0]}")
78+
pull_params+=("--parallel")
79+
fi
80+
81+
if [ "$(plugin_read_config QUIET_PULL "false")" == "true" ] ; then
82+
pull_params+=("--quiet")
7983
fi
8084

8185
# Pull down specified services
8286
if [[ ${#pull_services[@]} -gt 0 ]] && [[ "$(plugin_read_config SKIP_PULL "false")" != "true" ]]; then
8387
echo "~~~ :docker: Pulling services ${pull_services[0]}"
84-
retry "$pull_retries" run_docker_compose "${pull_params[@]}"
88+
retry "$pull_retries" run_docker_compose "${pull_params[@]}" "${pull_services[@]}"
8589
fi
8690

8791
# We set a predictable container name so we can find it and inspect it later on

plugin.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ configuration:
132132
type: integer
133133
quiet-pull:
134134
type: boolean
135+
quiet-push:
136+
type: boolean
135137
require-prebuild:
136138
type: boolean
137139
rm:
@@ -210,7 +212,8 @@ configuration:
210212
pull: [ run ]
211213
pull-retries: [ run ]
212214
push-retries: [ push ]
213-
quiet-pull: [ run ]
215+
quiet-pull: [ push, run]
216+
quiet-push: [ push ]
214217
require-prebuild: [ run ]
215218
rm: [ run ]
216219
run-image: [ run ]

0 commit comments

Comments
 (0)