Skip to content

Instantly share code, notes, and snippets.

@Halleck45
Created May 28, 2014 14:57
Show Gist options
  • Save Halleck45/be9eb3270cea0c9c28ab to your computer and use it in GitHub Desktop.
Save Halleck45/be9eb3270cea0c9c28ab to your computer and use it in GitHub Desktop.
.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