diff --git a/README.md b/README.md index d53066f5..8765d1a9 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/commands/run.sh b/commands/run.sh index 9f15be28..eaa14c00 100755 --- a/commands/run.sh +++ b/commands/run.sh @@ -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 diff --git a/tests/run.bats b/tests/run.bats index 94daae9a..7b445310 100644 --- a/tests/run.bats +++ b/tests/run.bats @@ -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 @@ -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 @@ -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