Skip to content

Instantly share code, notes, and snippets.

@ben-rogerson
Last active May 30, 2018 00:15
Show Gist options
  • Save ben-rogerson/739c49c6417c0155ab12d7049381072b to your computer and use it in GitHub Desktop.
Save ben-rogerson/739c49c6417c0155ab12d7049381072b to your computer and use it in GitHub Desktop.
Build Process
#set ($releaseId = ${execution.to_revision.revision} + '-' + ${execution.id} )
mkdir -p deploy-cache
mkdir -p shared
mkdir -p releases
if [ "${execution.refresh}" = "true" ]; then echo "Removing: deploy-cache" && rm -rf deploy-cache/*; fi
if [ -d "releases/${releaseId}" ] && [ "${execution.refresh}" = "true" ]; then echo "Removing: releases/${releaseId}" && rm -rf releases/${releaseId}; fi
# Executed on the first pipeline execution only
# Popular use case: install packages required by your Run Commands
# Changing the image in the Environment tab will run the commands again
apt-get update && apt-get install -y wget git zip
# curl -L https://phar.phpunit.de/phpunit.phar -o /usr/local/bin/phpunit
# chmod +x /usr/local/bin/phpunit
curl -sSv https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
#set ($releaseId = ${execution.to_revision.revision} + '-' + ${execution.id} )
if [ ! -d "releases/${releaseId}" ]; then echo "Creating: releases/${releaseId}" && cp -a deploy-cache releases/${releaseId}; fi
if [ $( ls -1d ${working_dir}/releases/* | wc -l ) -gt $( expr ${previous_releases_to_keep} + 1 ) ]; then echo "Deleting the following directories"; ls -t -1d ${working_dir}/releases/* | \tail -n +$( expr ${previous_releases_to_keep} + 1 ); \ls -t -1d ${working_dir}/releases/* | \tail -n +$( expr ${previous_releases_to_keep} + 1 ) | \xargs /bin/rm -rf; fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment