From 3585081d4d9c8f2344bb11c2c961561e70c99887 Mon Sep 17 00:00:00 2001 From: zaro0508 Date: Fri, 21 Jun 2013 11:12:55 -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 runs in prebuilder step which occurs after a build environment step. We want the script to run after gerrit-git-prep so we are calling the gerrit-git-prep in script so it will run in correct order. Change-Id: Iedd7561b4ef8e19b3713b63bb76b9b754ce116e9 Reviewed-on: https://review.openstack.org/34023 Reviewed-by: Clark Boylan Approved: James E. Blair Reviewed-by: James E. Blair Tested-by: Jenkins --- .../jenkins/files/slave_scripts/maven-properties.sh | 5 ++++- .../config/jenkins-plugin-jobs.yaml | 13 +++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/jenkins/files/slave_scripts/maven-properties.sh b/modules/jenkins/files/slave_scripts/maven-properties.sh index bf20bcac75..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 @@ -26,5 +29,5 @@ else fi echo "SCM_SHA=$SCM_SHA" >maven.properties -echo "COMMITS_SINCE_TAG=$COMMITS_SINCE_TAG" >>maven.properties echo "PROJECT_VER=$PROJECT_VER" >>maven.properties +echo "COMMITS_SINCE_TAG=$COMMITS_SINCE_TAG" >>maven.properties 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 ce4845598e..794d79d5e7 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,13 +1,15 @@ +# 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 - - shell: "/usr/local/jenkins/slave_scripts/maven-properties.sh" + wrappers: - inject: properties-file: maven.properties + script-file: /usr/local/jenkins/slave_scripts/maven-properties.sh maven: maven-name: Maven3 @@ -25,11 +27,10 @@ project-type: maven node: precise - prebuilders: - - gerrit-git-prep - - shell: "/usr/local/jenkins/slave_scripts/maven-properties.sh" + wrappers: - inject: properties-file: maven.properties + script-file: /usr/local/jenkins/slave_scripts/maven-properties.sh maven: maven-name: Maven3