
running the bash script with a properties build wrapper doesn't work because the wrapper runs before a scm checkout since the script queries git it needs to be run after checkout. This commit uses the shell builder to run the script then the evninject builder to read the generated properties file to make it available to the rest of the build. Fixed the script to always return 0 exit code on git commands. Also changed $() to back ticks for consistency. Change-Id: I1f31076762fb1d33d7e889fd2de4cf28d64d922d Reviewed-on: https://review.openstack.org/33471 Reviewed-by: Clark Boylan <clark.boylan@gmail.com> Approved: Jeremy Stanley <fungi@yuggoth.org> Reviewed-by: Jeremy Stanley <fungi@yuggoth.org> Tested-by: Jenkins
31 lines
1001 B
Bash
Executable File
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 "COMMITS_SINCE_TAG=$COMMITS_SINCE_TAG" >>maven.properties
|
|
echo "PROJECT_VER=$PROJECT_VER" >>maven.properties
|