From 688bdd459e85cd93c35435e03285355da536f26c Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Thu, 27 Feb 2014 15:11:42 -0800 Subject: [PATCH] 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 --- .../files/slave_scripts/version-properties.sh | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 modules/jenkins/files/slave_scripts/version-properties.sh diff --git a/modules/jenkins/files/slave_scripts/version-properties.sh b/modules/jenkins/files/slave_scripts/version-properties.sh new file mode 100755 index 0000000000..7dffc05e9d --- /dev/null +++ b/modules/jenkins/files/slave_scripts/version-properties.sh @@ -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