Skip to content

Commit

Permalink
Merge pull request #337 from buildkite-plugins/toote_issue-312
Browse files Browse the repository at this point in the history
Warnings with step-level array commands
  • Loading branch information
pzeballos authored Sep 23, 2022
2 parents 2da89a5 + 2135751 commit 0d1f977
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ steps:
run: app
```
:warning: Warning: you should not use this plugin with an array of commands at the step level. Execute a script in your repository, a single command separated by `;` or the plugin's [`command` option](#command-optional-run-only-array) instead.

You can also specify a custom Docker Compose config file and what environment to pass
through if you need:

Expand Down
6 changes: 6 additions & 0 deletions commands/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ if [[ ${#shell[@]} -gt 0 ]] ; then
fi

if [[ -n "${BUILDKITE_COMMAND}" ]] ; then
if [[ $(echo "$BUILDKITE_COMMAND" | wc -l) -gt 1 ]]; then
# An array of commands in the step will be a single string with multiple lines
# This breaks a lot of things here so we will print a warning for user to be aware
echo "⚠️ Warning: The command received has multiple lines."
echo "⚠️ The Docker Compose Plugin does not correctly support step-level array commands."
fi
run_params+=("${BUILDKITE_COMMAND}")
display_command+=("'${BUILDKITE_COMMAND}'")
elif [[ ${#command[@]} -gt 0 ]] ; then
Expand Down
3 changes: 3 additions & 0 deletions tests/run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ load '../lib/run'
run $PWD/hooks/command

assert_success
refute_output --partial "The Docker Compose Plugin does not correctly support step-level array commands"
assert_output --partial "built myservice"
assert_output --partial "ran myservice"
unstub docker-compose
Expand Down Expand Up @@ -135,6 +136,7 @@ cmd3"
run $PWD/hooks/command

assert_success
assert_output --partial "The Docker Compose Plugin does not correctly support step-level array commands"
assert_output --partial "built myservice"
assert_output --partial "ran myservice"
unstub docker-compose
Expand Down Expand Up @@ -163,6 +165,7 @@ cmd3"
run $PWD/hooks/command

assert_success
refute_output --partial "The Docker Compose Plugin does not correctly support step-level array commands"
assert_output --partial "built myservice"
assert_output --partial "ran myservice"
unstub docker-compose
Expand Down

0 comments on commit 0d1f977

Please sign in to comment.