Skip to content

Instantly share code, notes, and snippets.

@dfeyer
Forked from Halleck45/travis-jenkins-docker.sh
Last active August 29, 2015 14:12
Show Gist options
  • Save dfeyer/8c0f18a47a72e81e1afa to your computer and use it in GitHub Desktop.
Save dfeyer/8c0f18a47a72e81e1afa to your computer and use it in GitHub Desktop.
#!/bin/bash
EXIT_STATUS=0
echo "#!/bin/bash" > ./docker-travis-test.sh
cat .travis.yml | shyaml get-values before_script >> ./docker-travis-test.sh
cat .travis.yml | shyaml get-values script >> ./docker-travis-test.sh
PHP_VERSIONS=`cat .travis.yml | shyaml get-values php`
for PHP_VERSION in $PHP_VERSIONS
do
echo
echo "Running tests for PHP $PHP_VERSION"
echo "==================================="
DOCKER_IMG=debian/$PHP_VERSION
DOCKER_ID=$(docker run -d -t $DOCKER_IMG /bin/bash)
docker run -v `pwd`:/project -w "/project" -t $DOCKER_IMG /bin/bash ./docker-travis-test.sh
CODE=$?
case "$CODE" in
0) RESULT="OK"
OUTPUT="${OUTPUT}PHP ${PHP_VERSION}: OK \n"
;;
*)
RESULT="ERROR ($CODE)"
OUTPUT="${OUTPUT}PHP ${PHP_VERSION}: Error (code ${CODE}) \n"
EXIT_STATUS=1
;;
esac
DOCKER_IDS="${DOCKER_IDS} ${DOCKER_ID}"
done
docker restart $DOCKER_ID
$(docker wait ${DOCKER_IDS})
echo
echo "Results"
echo "==================================="
echo -e $OUTPUT;
exit $EXIT_STATUS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment