Created
October 17, 2013 18:25
-
-
Save ncdc/7029808 to your computer and use it in GitHub Desktop.
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
source $OPENSHIFT_CARTRIDGE_SDK_BASH | |
alias rsync="rsync --delete-after -az -e '$GIT_SSH'" | |
upstream_ssh="525ffd06f335d37c9d000011@p-${OPENSHIFT_NAMESPACE}.dev.rhcloud.com" | |
# Jenkins will have already cloned from git into $OPENSHIFT_HOMEDIR/app-root/runtime/repo | |
# need to preserve it so we can move it to the new deployment dir | |
mv $OPENSHIFT_HOMEDIR/app-root/runtime/repo $OPENSHIFT_HOMEDIR/app-root/runtime/repo.tmp | |
# Create a new deployment dir | |
local_deployment_dir=`gear create-deployment-dir` | |
# Remove the repo dir that was created in the new deployment dir | |
rmdir $OPENSHIFT_HOMEDIR/app-deployments/$local_deployment_dir/repo | |
# Move in the preserved repo into the new deployment dir | |
mv $OPENSHIFT_HOMEDIR/app-root/runtime/repo.tmp $OPENSHIFT_HOMEDIR/app-deployments/$local_deployment_dir/repo | |
# Set up symlinks | |
ln -nsf $OPENSHIFT_HOMEDIR/app-deployments/$local_deployment_dir/build-dependencies $OPENSHIFT_HOMEDIR/app-root/runtime/build-dependencies | |
ln -nsf $OPENSHIFT_HOMEDIR/app-deployments/$local_deployment_dir/dependencies $OPENSHIFT_HOMEDIR/app-root/runtime/dependencies | |
ln -nsf $OPENSHIFT_HOMEDIR/app-deployments/$local_deployment_dir/repo $OPENSHIFT_HOMEDIR/app-root/runtime/repo | |
if ! marker_present "force_clean_build"; then | |
# don't fail if these rsyncs fail | |
set +e | |
rsync $upstream_ssh:'$OPENSHIFT_BUILD_DEPENDENCIES_DIR' $OPENSHIFT_BUILD_DEPENDENCIES_DIR | |
rsync $upstream_ssh:'$OPENSHIFT_DEPENDENCIES_DIR' $OPENSHIFT_DEPENDENCIES_DIR | |
set -e | |
fi | |
# Build/update libs and run user pre_build and build | |
gear build --git-ref $GIT_BRANCH | |
# Run tests here | |
# Deploy new build | |
# Stop app | |
$GIT_SSH $upstream_ssh "gear stop --conditional --exclude-web-proxy --git-ref $GIT_COMMIT" | |
deployment_dir=`$GIT_SSH $upstream_ssh 'gear create-deployment-dir'` | |
# Push content back to application | |
rsync $OPENSHIFT_HOMEDIR/app-deployments/*/metadata.json $upstream_ssh:app-deployments/$deployment_dir/metadata.json | |
rsync $WORKSPACE/ $upstream_ssh:app-deployments/$deployment_dir/repo/ | |
rsync $OPENSHIFT_BUILD_DEPENDENCIES_DIR $upstream_ssh:app-deployments/$deployment_dir/build-dependencies/ | |
rsync $OPENSHIFT_DEPENDENCIES_DIR $upstream_ssh:app-deployments/$deployment_dir/dependencies/ | |
# Configure / start app | |
$GIT_SSH $upstream_ssh "gear remotedeploy --deployment-datetime $deployment_dir" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment