Created
May 7, 2013 22:55
-
-
Save kvick/5536855 to your computer and use it in GitHub Desktop.
Jenkins Build step (execute shell) for aminator/testing. Make sure to set the environment variables (PYTHONPATH=${WORKSPACE}) so that the aminator_versioning.py can find the version file
The git publisher pushes $TAG to testing when the build succeeds
This file contains hidden or 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
PYTHON_COMMAND="python2.7" | |
UPDATE_VERSION_COMMAND="${PYTHON_COMMAND} /usr/local/bin/aminator_versioning.py" | |
MAJOR_MINOR_VERSION=`${UPDATE_VERSION_COMMAND} -d` | |
POSTFIX="dev" | |
# RPM doesn't support '-' | |
TAG="$MAJOR_MINOR_VERSION.${BUILD_NUMBER}-$POSTFIX" | |
RPM_TAG="$MAJOR_MINOR_VERSION.$POSTFIX${BUILD_NUMBER}" | |
VERSION_FILE=aminator/__init__.py | |
INSTALL_DIR="/apps/aminator" | |
FPM_COMMAND="/usr/local/bin/fpm" | |
PIP_COMMAND="pip" | |
# save this for later | |
echo "TAG=$TAG" > tag.properties | |
PIP_CACHE_DIR=${WORKSPACE}/pip-cache | |
if [ ! -d ${PIP_CACHE_DIR} ]; then | |
mkdir ${PIP_CACHE_DIR} | |
fi | |
# 1. the git plugin does the merge for us into a local workspace | |
# 2. bump the revision (run the UPDATE_VERSION_COMMAND) with the ${BUILD_NUMBER} | |
# 3. add/commit the version file | |
# 4. tag the commit | |
# 5. push to the remote branch | |
# 6. build a packages! | |
$UPDATE_VERSION_COMMAND -b ${BUILD_NUMBER} | |
git add $VERSION_FILE | |
# Build a virtualenv and install reqs and aminator | |
virtualenv $TAG | |
virtualenv --relocatable $TAG | |
source $TAG/bin/activate | |
${PIP_COMMAND} install --download-cache=${PIP_CACHE_DIR} -r requirements.txt | |
${PYTHON_COMMAND} setup.py install | |
# need to run virtualenv --relocatable again to update all the paths to relative paths | |
virtualenv --relocatable $TAG | |
sed -i "s#^VIRTUAL_ENV=.*#VIRTUAL_ENV=\"${INSTALL_DIR}/$TAG\"#" $TAG/bin/activate | |
pip freeze > requirements-locked.txt | |
sed -i '/^aminator/d' requirements-locked.txt | |
git add requirements-locked.txt | |
git commit -m "prepare for release $TAG" | |
# DEB | |
$FPM_COMMAND -s dir -t deb -n "aminator" -v $TAG --deb-user="root" -a all --prefix="${INSTALL_DIR}" $TAG | |
# RPM | |
$FPM_COMMAND -s dir -t rpm -n "aminator" -v $RPM_TAG --rpm-user="root" -a all --prefix="${INSTALL_DIR}" $TAG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment