Skip to content

Commit

Permalink
Merge pull request #55 from buildkite-plugins/make-sure-to-error-on-m…
Browse files Browse the repository at this point in the history
…ultiple-command-failure

Make sure to exit 1 if any command fails
  • Loading branch information
toolmantim authored Jul 6, 2018
2 parents 988131e + c580bc8 commit e6a11d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Example: `nvidia`

### `shell` (optional)

Set the shell to use for the command. Set it to `false` to pass the command directly to the `docker run` command. The default is `bash -c`.
Set the shell to use for the command. Set it to `false` to pass the command directly to the `docker run` command. The default is `bash -e -c`.

Example: `powershell -Command`

Expand Down
2 changes: 1 addition & 1 deletion hooks/command
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if [[ -n "${BUILDKITE_PLUGIN_DOCKER_ENTRYPOINT:-}" ]] ; then
BUILDKITE_PLUGIN_DOCKER_SHELL="${BUILDKITE_PLUGIN_DOCKER_SHELL:-false}"
fi

BUILDKITE_PLUGIN_DOCKER_SHELL="${BUILDKITE_PLUGIN_DOCKER_SHELL:-bash -c}"
BUILDKITE_PLUGIN_DOCKER_SHELL="${BUILDKITE_PLUGIN_DOCKER_SHELL:-bash -e -c}"

if [[ "${BUILDKITE_PLUGIN_DOCKER_SHELL}" =~ ^(false|off|0)$ ]] ; then
BUILDKITE_PLUGIN_DOCKER_SHELL=''
Expand Down
22 changes: 11 additions & 11 deletions tests/command.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ load '/usr/local/lib/bats/load.bash'
export BUILDKITE_AGENT_BINARY_PATH="/buildkite-agent"

stub docker \
"run -it --rm --volume $PWD:/app --workdir /app --env BUILDKITE_JOB_ID --env BUILDKITE_BUILD_ID --env BUILDKITE_AGENT_ACCESS_TOKEN --volume /buildkite-agent:/usr/bin/buildkite-agent image:tag bash -c 'command1 \"a string\"' : echo ran command in docker"
"run -it --rm --volume $PWD:/app --workdir /app --env BUILDKITE_JOB_ID --env BUILDKITE_BUILD_ID --env BUILDKITE_AGENT_ACCESS_TOKEN --volume /buildkite-agent:/usr/bin/buildkite-agent image:tag bash -e -c 'command1 \"a string\"' : echo ran command in docker"

run $PWD/hooks/command

Expand All @@ -31,7 +31,7 @@ load '/usr/local/lib/bats/load.bash'
export BUILDKITE_AGENT_BINARY_PATH="/buildkite-agent"

stub docker \
"run -it --rm --volume $PWD:/workdir --workdir /workdir --env BUILDKITE_JOB_ID --env BUILDKITE_BUILD_ID --env BUILDKITE_AGENT_ACCESS_TOKEN --volume /buildkite-agent:/usr/bin/buildkite-agent image:tag bash -c 'command1 \"a string\"' : echo ran command in docker"
"run -it --rm --volume $PWD:/workdir --workdir /workdir --env BUILDKITE_JOB_ID --env BUILDKITE_BUILD_ID --env BUILDKITE_AGENT_ACCESS_TOKEN --volume /buildkite-agent:/usr/bin/buildkite-agent image:tag bash -e -c 'command1 \"a string\"' : echo ran command in docker"

run $PWD/hooks/command

Expand All @@ -53,7 +53,7 @@ load '/usr/local/lib/bats/load.bash'

stub docker \
"pull image:tag : echo pulled latest image" \
"run -it --rm --volume $PWD:/app --workdir /app image:tag bash -c 'pwd' : echo ran command in docker"
"run -it --rm --volume $PWD:/app --workdir /app image:tag bash -e -c 'pwd' : echo ran command in docker"

run $PWD/hooks/command

Expand All @@ -77,7 +77,7 @@ load '/usr/local/lib/bats/load.bash'
export BUILDKITE_COMMAND="pwd"

stub docker \
"run -it --rm --volume $PWD:/app --workdir /app image:tag bash -c 'pwd' : echo ran command in docker"
"run -it --rm --volume $PWD:/app --workdir /app image:tag bash -e -c 'pwd' : echo ran command in docker"

run $PWD/hooks/command

Expand All @@ -100,7 +100,7 @@ load '/usr/local/lib/bats/load.bash'
export BUILDKITE_COMMAND="echo hello world; pwd"

stub docker \
"run -it --rm --volume $PWD:/app --workdir /app --volume /hello:/hello-world --volume /var/run/docker.sock:/var/run/docker.sock image:tag bash -c 'echo hello world; pwd' : echo ran command in docker"
"run -it --rm --volume $PWD:/app --workdir /app --volume /hello:/hello-world --volume /var/run/docker.sock:/var/run/docker.sock image:tag bash -e -c 'echo hello world; pwd' : echo ran command in docker"

run $PWD/hooks/command

Expand All @@ -125,7 +125,7 @@ load '/usr/local/lib/bats/load.bash'
export BUILDKITE_COMMAND="echo hello world"

stub docker \
"run -it --rm --volume $PWD:/app --workdir /app --env MY_TAG=value --env ANOTHER_TAG=llamas image:tag bash -c 'echo hello world' : echo ran command in docker"
"run -it --rm --volume $PWD:/app --workdir /app --env MY_TAG=value --env ANOTHER_TAG=llamas image:tag bash -e -c 'echo hello world' : echo ran command in docker"

run $PWD/hooks/command

Expand All @@ -148,7 +148,7 @@ load '/usr/local/lib/bats/load.bash'
export BUILDKITE_COMMAND="echo hello world"

stub docker \
"run -it --rm --volume $PWD:/app --workdir /app -u foo image:tag bash -c 'echo hello world' : echo ran command in docker"
"run -it --rm --volume $PWD:/app --workdir /app -u foo image:tag bash -e -c 'echo hello world' : echo ran command in docker"

run $PWD/hooks/command

Expand All @@ -171,7 +171,7 @@ load '/usr/local/lib/bats/load.bash'
export BUILDKITE_COMMAND="echo hello world"

stub docker \
"run -it --rm --volume $PWD:/app --workdir /app --group-add foo --group-add bar image:tag bash -c 'echo hello world' : echo ran command in docker"
"run -it --rm --volume $PWD:/app --workdir /app --group-add foo --group-add bar image:tag bash -e -c 'echo hello world' : echo ran command in docker"

run $PWD/hooks/command

Expand All @@ -196,7 +196,7 @@ load '/usr/local/lib/bats/load.bash'
stub docker \
"network ls --quiet --filter 'name=foo' : echo " \
"network create foo : echo creating network foo" \
"run -it --rm --volume $PWD:/app --workdir /app --network foo image:tag bash -c 'echo hello world' : echo ran command in docker"
"run -it --rm --volume $PWD:/app --workdir /app --network foo image:tag bash -e -c 'echo hello world' : echo ran command in docker"

run $PWD/hooks/command

Expand All @@ -220,7 +220,7 @@ load '/usr/local/lib/bats/load.bash'
export BUILDKITE_COMMAND="echo hello world"

stub docker \
"run -it --rm --volume $PWD:/app --workdir /app image:tag bash -c 'echo hello world' : echo ran command in docker"
"run -it --rm --volume $PWD:/app --workdir /app image:tag bash -e -c 'echo hello world' : echo ran command in docker"

run $PWD/hooks/command

Expand All @@ -244,7 +244,7 @@ load '/usr/local/lib/bats/load.bash'
export BUILDKITE_COMMAND="echo hello world"

stub docker \
"run -it --rm --volume $PWD:/app --workdir /app --runtime custom_runtime image:tag bash -c 'echo hello world' : echo ran command in docker"
"run -it --rm --volume $PWD:/app --workdir /app --runtime custom_runtime image:tag bash -e -c 'echo hello world' : echo ran command in docker"

run $PWD/hooks/command

Expand Down

0 comments on commit e6a11d4

Please sign in to comment.