Created
September 17, 2015 19:13
-
-
Save abrader/cdb874e0e31966ac0a6a to your computer and use it in GitHub Desktop.
Script for returning commit hash for use with Puppet environments
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
| #! /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