Skip to content

Instantly share code, notes, and snippets.

@kevinchampion
Created December 12, 2013 00:19
Show Gist options
  • Save kevinchampion/7921100 to your computer and use it in GitHub Desktop.
Save kevinchampion/7921100 to your computer and use it in GitHub Desktop.
Jenkins builds repo
CLIENT="$1"
SITE="$2"
VHOST="$3"
cd /var/www/vhosts/${VHOST}/public
# Remove all the gitignores
find . -name ".gitignore" -print0 | xargs -0 rm
# Create repo
git init
# Add full site gitignore
git remote add origin /var/www/builds/${CLIENT}/${SITE}
git fetch origin
git checkout origin/7.x-1.x-builds .gitignore
# Create a tag name
tag=`date +%Y-%m-%dT%H%M`
# We could use other methods of constructing the tag name.
# count=`git tag -l "$timestamp-*" | wc -l`
# tag=$timestamp-`expr $count + 1`
git add .
git commit -m "Build $tag"
git checkout -b 7.x-1.x-builds
# git branch -D master
# Rebase with a merge strategy that ensures their won't be conflicts.
# Couldn't get this to work
# git rebase --strategy="recursive" --strategy-option="theirs" origin/7.x-1.x-dev
# Merge: use strategy=ours here because we only want the new build contents.
git merge --strategy=ours origin/7.x-1.x-builds
git push origin 7.x-1.x-builds
# Solicit optional git tag -m message
#echo -n "Did the build go well? Does your inspection of the site pass? (y/n) "
#read deploy
# Create the tag
git tag $tag
git push origin --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment