start of a ci script

This commit is contained in:
Derek Higgins 2013-05-15 10:16:30 +01:00
commit 4d0af400e3
5 changed files with 43 additions and 0 deletions

24
toci.sh Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/bash
export STARTTIME=$(date)
export TOCI_WORKING_DIR=$(mktemp -d)
export TOCI_LOG_DIR=$(mktemp -d)
echo $TOCI_LOG_DIR
STATUS=0
./toci_setup.sh > $TOCI_LOG_DIR/setup.out 2>&1 || STATUS=1
if [ $STATUS == 0 ] ; then
./toci_test.sh > $TOCI_LOG_DIR/test.out 2>&1 || STATUS=1
fi
./toci_cleanup.sh > $TOCI_LOG_DIR/cleanup.out 2>&1 || STATUS=1
cd $(dirname $TOCI_LOG_DIR)
tar -czf - $(basename $TOCI_LOG_DIR) | ssh ec2-user@toci_results tar -C /var/www/html/toci -xzf -
if [ $STATUS == 0 ] ; then
ssh ec2-user@toci_results "echo \<a href=\"$(basename $TOCI_LOG_DIR)\"\>$STARTTIME : OK\</a\>\<br/\> >> /var/www/html/toci/index.html ; chmod -R 775 /var/www/html/toci/*"
else
ssh ec2-user@toci_results "echo \<a style=\\\"COLOR: \#FF0000\\\" href=\"$(basename $TOCI_LOG_DIR)\"\>$STARTTIME : ERR\</a\>\<br/\> >> /var/www/html/toci/index.html ; chmod -R 775 /var/www/html/toci/*"
fi

2
toci_cleanup.sh Executable file
View File

@ -0,0 +1,2 @@
set -xe

2
toci_setup.sh Executable file
View File

@ -0,0 +1,2 @@
set -xe

2
toci_test.sh Executable file
View File

@ -0,0 +1,2 @@
set -xe

13
updated_launch.sh Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
LOCKFILE=/var/tmp/toci.lock
GITREF=${1:-origin/master}
cd $(dirname $0)
git fetch origin
# Exit if there is a script already running, otherwise update repo
# TODO : fix small race condition here (probably not a problem)
flock -x -n $LOCKFILE git reset --hard $GITREF || exit 0
flock -x -n $LOCKFILE ./toci.sh