From 9e258ea5aa6c2d18d5aaab2c54fb414727372bf5 Mon Sep 17 00:00:00 2001
From: zaro0508 <zaro0508@gmail.com>
Date: Fri, 12 Jul 2013 11:27:57 -0700
Subject: [PATCH] workaround for jenkins bug
 https://issues.jenkins-ci.org/browse/JENKINS-14193

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
---
 modules/jenkins/files/slave_scripts/maven-properties.sh  | 3 +++
 .../jenkins_job_builder/config/jenkins-plugin-jobs.yaml  | 9 +++------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/modules/jenkins/files/slave_scripts/maven-properties.sh b/modules/jenkins/files/slave_scripts/maven-properties.sh
index 7386acb20c..e585462318 100755
--- a/modules/jenkins/files/slave_scripts/maven-properties.sh
+++ b/modules/jenkins/files/slave_scripts/maven-properties.sh
@@ -5,6 +5,9 @@
 # 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
diff --git a/modules/openstack_project/files/jenkins_job_builder/config/jenkins-plugin-jobs.yaml b/modules/openstack_project/files/jenkins_job_builder/config/jenkins-plugin-jobs.yaml
index d3aed9a4ba..da638425bf 100644
--- a/modules/openstack_project/files/jenkins_job_builder/config/jenkins-plugin-jobs.yaml
+++ b/modules/openstack_project/files/jenkins_job_builder/config/jenkins-plugin-jobs.yaml
@@ -1,11 +1,11 @@
+# need to run gerrit-git-prep in maven-properties.sh script to work
+# around jenkins bug: https://issues.jenkins-ci.org/browse/JENKINS-14193
+
 - job-template:
     name: 'gate-{name}-build'
     project-type: maven
     node: precise
 
-    prebuilders:
-      - gerrit-git-prep
-
     wrappers:
       - timeout:
           timeout: 30
@@ -32,9 +32,6 @@
     project-type: maven
     node: precise
 
-    prebuilders:
-      - gerrit-git-prep
-
     wrappers:
       - timeout:
           timeout: 30