Skip to content

Commit

Permalink
Merge pull request buildkite-plugins#211 from pecigonzalo/feature/rm-…
Browse files Browse the repository at this point in the history
…option

Add --rm option as default for runs
  • Loading branch information
toolmantim authored Apr 8, 2019
2 parents a7cb30c + 51857f2 commit 55945d3
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 24 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ Sets `docker-compose` to run with `--verbose`

The default is `false`.

### `rm` (optional, run only)

If set to true, docker compose will remove the primary container after run. Equivalent to `--rm` in docker-compose.

The default is `true`.

## Developing

To run the tests:
Expand Down
5 changes: 5 additions & 0 deletions commands/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ if [[ "$(plugin_read_config USE_ALIASES "false")" == "true" ]] ; then
run_params+=(--use-aliases)
fi

# Optionally remove containers after run
if [[ "$(plugin_read_config RM "true")" == "true" ]]; then
run_params+=(--rm)
fi

run_params+=("$run_service")

if [[ "${BUILDKITE_PLUGIN_DOCKER_COMPOSE_REQUIRE_PREBUILD:-}" =~ ^(true|on|1)$ ]] && [[ ! -f "$override_file" ]] ; then
Expand Down
9 changes: 7 additions & 2 deletions lib/run.bash
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ check_linked_containers_and_save_logs() {
mkdir -p "$logdir"

while read -r line ; do
service_name="$(cut -d$'\t' -f2 <<< "$line")"
service_container_id="$(cut -d$'\t' -f1 <<< "$line")"
if [[ -z "${line}" ]]; then
# Skip empty lines
continue
fi

service_name="$(cut -d$'\t' -f2 <<<"$line")"
service_container_id="$(cut -d$'\t' -f1 <<<"$line")"

if [[ "$service_name" == "$service" ]] ; then
continue
Expand Down
2 changes: 2 additions & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ configuration:
type: boolean
workdir:
type: string
rm:
type: boolean
oneOf:
- required:
- run
Expand Down
Loading

0 comments on commit 55945d3

Please sign in to comment.