Skip to content

Instantly share code, notes, and snippets.

@abrader
Created September 17, 2015 19:13
Show Gist options
  • Select an option

  • Save abrader/cdb874e0e31966ac0a6a to your computer and use it in GitHub Desktop.

Select an option

Save abrader/cdb874e0e31966ac0a6a to your computer and use it in GitHub Desktop.
Script for returning commit hash for use with Puppet environments
#! /bin/sh
if (( $# != 1 )); then
echo "Call this script with the name of the environment"
echo "Example: ${0} production"
exit 1
fi
ENVROOT='/etc/puppetlabs/code/environments'
GITDIR="${ENVROOT}/${1}/.git"
# check to make sure the env repo exists
if [ -d ${GITDIR} ];
then
git --git-dir ${GITDIR} rev-parse --short HEAD
else
date '+%s'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment