Forked from christian-oudard/hudson fabric deploy bash script
Created
February 25, 2010 22:52
-
-
Save winhamwr/315136 to your computer and use it in GitHub Desktop.
Hudson fabric deployment script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#http://gist.github.com/gists/315136 | |
SSHAGENT=/usr/bin/ssh-agent | |
SSHAGENTARGS="-s" | |
PARENT_JOB=pstat_master_unittest | |
KEY_PATH=$HOME/policystat/fabric/pstat_dev.key | |
PROJECT_ROOT=/var/www/pstattest.com/ | |
DB_NAME=pstattest | |
if [ ! -z "$WORKSPACE" ]; then | |
WORKSPACE=/vol/fs/var/lib/hudson/home/jobs/pstat_master_deploy/workspace | |
fi | |
set -e | |
set -x | |
# Start the ssh-agent | |
if [ -z "$SSH_AUTH_SOCK" ]; then | |
eval `$SSHAGENT $SSHAGENTARGS` | |
trap "kill $SSH_AGENT_PID" 0 | |
fi | |
echo $SSH_AGENT_PID | |
/usr/bin/ssh-add $KEY_PATH | |
# Remove the fabric output so we fail if fabric doesn't run | |
rm $WORKSPACE/fabric.out | |
# Reset the database | |
mysql -u root -e "DROP DATABASE IF EXISTS $DB_NAME;" | |
# Run deployment | |
. $WORKSPACE/../../../virtualenvs/$PARENT_JOB/bin/activate | |
cd $WORKSPACE/../../$PARENT_JOB/workspace/pstat | |
fab test update deploy &> $WORKSPACE/fabric.out | |
# Load initial fixtures | |
# Have to switch to the target project virtual environment | |
deactivate | |
. /home/policystat/env/bin/activate | |
python $PROJECT_ROOT/scripts/load_testing_fixtures.py | |
set +x | |
# Kill ssh-agent | |
ssh-add -D | |
set +e | |
ssh-agent -k > /dev/null 2>&1 | |
unset SSH_AGENT_PID | |
unset SSH_AUTH_SOCK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment