Skip to content

Instantly share code, notes, and snippets.

@winhamwr
Created February 4, 2010 16:56
Show Gist options
  • Save winhamwr/294861 to your computer and use it in GitHub Desktop.
Save winhamwr/294861 to your computer and use it in GitHub Desktop.
hudson virtualenv creation
#!/bin/bash
# Hosted at: http://gist.github.com/294861
SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS="-s"
# Job we're using for deploying the virtualenv
PARENT_JOB=pstat_master_unittest
KEY_PATH=$HOME/policystat/fabric/pstat_dev.key
SSH_ADD=/usr/bin/ssh-add
VIRTUALENVWRAPPER_BASHRC=/usr/bin/virtualenvwrapper_bashrc
if [ ! -z "$JOB_NAME" ]; then
JOB_NAME=pstat_master_slow_unittest
fi
if [ ! -z "$WORKSPACE" ]; then
WORKSPACE=/vol/fs/var/lib/hudson/home/jobs/$JOB_NAME/workspace
fi
WORKON_HOME=$WORKSPACE/../../../virtualenvs
VENV_DIR=$WORKSPACE/../../../virtualenvs/$JOB_NAME
PARENT_WORKSPACE=$WORKSPACE/../../$PARENT_JOB/workspace
PARENT_VENV_DIR=$WORKSPACE/../../../virtualenvs/$PARENT_JOB
set -e
set -v
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
$SSH_ADD $KEY_PATH
. $PARENT_VENV_DIR/bin/activate
cd $PARENT_WORKSPACE/pstat
# Delete the virtualenv and build it from scratch
rm -r -f $VENV_DIR
# We have a bootstrapping problem. We need fabric installed and pstat on the path in order to run the deploy
virtualenv $VENV_DIR
. $VENV_DIR/bin/activate
easy_install pip>=0.6.3
pip install Fabric==0.9.0
pip install boto==1.9b
set +x
set +v
. $VIRTUALENVWRAPPER_BASHRC
add2virtualenv $WORKSPACE
add2virtualenv $WORKSPACE/pstat
set -x
set -v
# Now run the actual fab deployment setup
fab test update setup_build_env:job=$JOB_NAME &> $WORKSPACE/fabric.out
set +x
# Kill ssh-agent
ssh-add -D
set +e
ssh-agent -k
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