Move git config to a common function/file

There are a number of calls to git config in the slave scripts are
all the same, and we should use a shell function to not repeat
ourselves.

Change-Id: Ib2fa3d5ca12d5d08e2d21a734fea13aa9848b19e
This commit is contained in:
Steve Kowalik 2015-05-20 14:17:05 -07:00
parent 5140cb0832
commit c7ac961329
4 changed files with 27 additions and 16 deletions

18
jenkins/scripts/common.sh Normal file
View File

@ -0,0 +1,18 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# Setup git so that git review works
function setup_git {
git config user.name "OpenStack Proposal Bot"
git config user.email "openstack-infra@lists.openstack.org"
git config gitreview.username "proposal-bot"
}

View File

@ -14,6 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
source /usr/local/jenkins/slave_scripts/common.sh
# Used for setup.py babel commands
QUIET="--quiet"
@ -156,13 +158,6 @@ function setup_manuals {
}
# Setup git so that git review works
function setup_git {
git config user.name "OpenStack Proposal Bot"
git config user.email "openstack-infra@lists.openstack.org"
git config gitreview.username "proposal-bot"
}
# Setup project so that git review works, sets global variable
# COMMIT_MSG.
function setup_review {

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
source /usr/local/jenkins/slave_scripts/common.sh
TAG=$1
# Only merge release tag if it's on a stable branch
@ -26,9 +28,7 @@ if ! echo $TAG|grep '^[0-9]\+\.[0-9]\+\(\.0\|\)$'; then
exit 0
fi
git config user.name "OpenStack Proposal Bot"
git config user.email "openstack-infra@lists.openstack.org"
git config gitreview.username "proposal-bot"
setup_git
git review -s
git remote update

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
source /usr/local/jenkins/slave_scripts/common.sh
OWN_PROJECT=$1
if [ -z "$OWN_PROJECT" ] ; then
echo "usage: $0 project"
@ -32,9 +34,7 @@ if [ -z "$ZUUL_REF" ] ; then
exit 1
fi
git config user.name "OpenStack Proposal Bot"
git config user.email "openstack-infra@lists.openstack.org"
git config gitreview.username "proposal-bot"
setup_git
for PROJECT in $(cat projects.txt); do
@ -98,9 +98,7 @@ EOF
git checkout -B ${BRANCH} -t origin/${BRANCH}
# Need to set the git config in each repo as we shouldn't
# set it globally for the Jenkins user on the slaves.
git config user.name "OpenStack Proposal Bot"
git config user.email "openstack-infra@lists.openstack.org"
git config gitreview.username "proposal-bot"
setup_git
# Do error checking manually to continue with the next project
# in case of failures like a broken .gitreview file.
set +e