Fix setting of properties

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
This commit is contained in:
zaro0508 2013-06-18 09:34:25 -07:00 committed by Jenkins
parent b38578664a
commit 39019818f6
2 changed files with 9 additions and 13 deletions

View File

@ -6,11 +6,11 @@
# versioned builds within the gerrit workflow. # versioned builds within the gerrit workflow.
# get version info from scm # get version info from scm
SCM_TAG=$(git describe --abbrev=0 --tags) || true SCM_TAG=`git describe --abbrev=0 --tags` || true
SCM_SHA=$(git rev-parse --short HEAD) SCM_SHA=`git rev-parse --short HEAD` || true
# assumes format is like this '0.0.4-2-g135721c' # assumes format is like this '0.0.4-2-g135721c'
COMMITS_SINCE_TAG=`git describe | awk '{split($0,a,"-"); print a[2]}'` COMMITS_SINCE_TAG=`git describe | awk '{split($0,a,"-"); print a[2]}'` || true
# just use git sha if there is no tag yet. # just use git sha if there is no tag yet.
if [[ "${SCM_TAG}" == "" ]]; then if [[ "${SCM_TAG}" == "" ]]; then

View File

@ -3,13 +3,11 @@
project-type: maven project-type: maven
node: precise node: precise
properties:
- inject:
script-file: /usr/local/jenkins/slave_scripts/maven-properties.sh
properties-file: maven.properties
prebuilders: prebuilders:
- gerrit-git-prep - gerrit-git-prep
- shell: "/usr/local/jenkins/slave_scripts/maven-properties.sh"
- inject:
properties-file: maven.properties
maven: maven:
maven-name: Maven3 maven-name: Maven3
@ -27,13 +25,11 @@
project-type: maven project-type: maven
node: precise node: precise
properties:
- inject:
script-file: /usr/local/jenkins/slave_scripts/maven-properties.sh
properties-file: maven.properties
prebuilders: prebuilders:
- gerrit-git-prep - gerrit-git-prep
- shell: "/usr/local/jenkins/slave_scripts/maven-properties.sh"
- inject:
properties-file: maven.properties
maven: maven:
maven-name: Maven3 maven-name: Maven3