mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
Docker CI Images should cleanup in the event of an unclean exit.
Fixes #9279
This commit is contained in:
parent
0680c9ec09
commit
7f4fcda8b0
1 changed files with 13 additions and 4 deletions
|
@ -11,17 +11,26 @@ if [ -z "$branch_specifier" ]; then
|
|||
REMOVE_IMAGE=true
|
||||
IMAGE_NAME="$1"
|
||||
else
|
||||
# Jenkins
|
||||
IMAGE_NAME=$branch_specifier"-"$(date +%s%N)
|
||||
fi
|
||||
|
||||
echo "Running Docker CI build for '$IMAGE_NAME' "
|
||||
|
||||
docker build -t $IMAGE_NAME .
|
||||
# Remove old docker cid just in case
|
||||
rm -f docker_cid
|
||||
|
||||
docker build -t $IMAGE_NAME .
|
||||
exit_code=$?; [[ $exit_code != 0 ]] && exit $exit_code
|
||||
|
||||
cleanup() {
|
||||
cat docker_cid | xargs docker rm --force -v
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Run the command, skip the first argument, which is the image name
|
||||
docker run --sig-proxy=true --rm $IMAGE_NAME ${@:2}
|
||||
echo "Running tests in built docker image"
|
||||
docker run --sig-proxy=true --cidfile=docker_cid --rm $IMAGE_NAME ${@:2}
|
||||
exit_code=$?
|
||||
[[ $REMOVE_IMAGE == "true" ]] && docker rmi $IMAGE_NAME
|
||||
echo "exiting with code: '$exit_code'"
|
||||
exit $exit_code #preserve the exit code from the test run
|
||||
exit $exit_code #preserve the exit code from the test run
|
Loading…
Add table
Add a link
Reference in a new issue