zaro0508 d1478aabf7 run script and load properties in correct order
By default the EnvInject plugin loads the properties
file before running the bash script when defined in wrapper
section.  However we want the opposite execution order, run script
then load properties file.

To work around this ordering problem we need to define
two instances of EnvInject, 1st instance to run the
script and 2nd instance to load the properties file.
This cannot be done in jenkins UI, but apparently works
when defined in JJB.

This will also let us run gerrit-git-prep in the
more conventional pre-builder step.

Change-Id: I7a16143a2f9b79d2dbe2684a7d016f6640f5a707
Reviewed-on: https://review.openstack.org/34936
Reviewed-by: James E. Blair <corvus@inaugust.com>
Reviewed-by: matthew wagoner <zxkuqyb@gmail.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
2013-07-08 22:25:06 +00:00

31 lines
1001 B
Bash
Executable File

#!/bin/bash -ex
# This file is a helper for versioning and deployment of
# maven projects. It sets up environment variables to
# pass to maven build commands so that we can generate
# versioned builds within the gerrit workflow.
# 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" >maven.properties
echo "PROJECT_VER=$PROJECT_VER" >>maven.properties
echo "COMMITS_SINCE_TAG=$COMMITS_SINCE_TAG" >>maven.properties