Create new version-properties.sh script

Create a new version-properties.sh script that will be used on slave
hosts to determine version information from git. This is mostly a copy
of the maven-properties.sh script. The reason we are not simply renaming
is that this commit must be merged then all slave images updated before
we change our jenkins jobs to use the new script. Renaming doesn't allow
us to do that.

Change-Id: I37c0b7cc3ca034addf32897a5a8c6501dedf00b0
This commit is contained in:
Clark Boylan 2014-02-27 15:11:42 -08:00
parent db20f1f27a
commit 688bdd459e

View File

@ -0,0 +1,29 @@
#!/bin/bash -ex
#
# This is a script that helps us version build artifacts. It retrieves
# git info and generates version strings.
#
# get version info from scm
SCM_TAG=`git describe --abbrev=0 --tags` || true
SCM_SHA=`git rev-parse --short HEAD` || true
# assumes format is like this '0.0.4-2-g135721c'
COMMITS_SINCE_TAG=`git describe | awk '{split($0,a,"-"); print a[2]}'` || true
# just use git sha if there is no tag yet.
if [[ "${SCM_TAG}" == "" ]]; then
SCM_TAG=$SCM_SHA
fi
# General build version should be something like '0.0.4.3.d4ee90c'
# Release build version should be something like '0.0.5'
if [[ "${COMMITS_SINCE_TAG}" == "" ]]; then
PROJECT_VER=$SCM_TAG
else
PROJECT_VER="$SCM_TAG.$COMMITS_SINCE_TAG.$SCM_SHA";
fi
echo "SCM_SHA=$SCM_SHA" >version.properties
echo "PROJECT_VER=$PROJECT_VER" >>version.properties
echo "COMMITS_SINCE_TAG=$COMMITS_SINCE_TAG" >>version.properties