Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
.travis.yml avec Jenkins et Docker
#!/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