9e258ea5aa
The jenkins maven builder cannot reference environment variables if it is set by the EnvInject plugin at the prebuilder step. However the maven builder CAN reference variables when loaded from the build environment setup (wrapper) step. The only problem is that gerrit-git-prep only runs in the prebuilder step which occurs aftern a build environment step (wrapper). We want the maven-properties.sh script to run after gerrit-git-prep because the it queries for git info. A workaround is to call gerrit-git-prep inside of the maven-properties script so it will run in the correct order. Change-Id: Ie0a72d8509f5f1453e027486285c2817dbc67eb5 Reviewed-on: https://review.openstack.org/36879 Reviewed-by: Clark Boylan <clark.boylan@gmail.com> Approved: James E. Blair <corvus@inaugust.com> Reviewed-by: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
34 lines
1.2 KiB
Bash
Executable File
34 lines
1.2 KiB
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.
|
|
|
|
# work around for jenkins bug: https://issues.jenkins-ci.org/browse/JENKINS-14193
|
|
/usr/local/jenkins/slave_scripts/gerrit-git-prep.sh https://review.openstack.org http://zuul.openstack.org
|
|
|
|
# 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
|