Jeremy Stanley a86367a84d If running git clean after reset then retry
* modules/jenkins/files/slave_scripts/gerrit-git-prep.sh
* .../openstack_project/files/jenkins_job_builder/config/macros.yaml
* .../infra-publications.yaml: If a git clean can not remove some
files, for example because a previous command has not freed its open
file handles, it will return nonzero. If this happens, wait a moment
and try again in case this is only a briefly transient problem.

Change-Id: If11320da7379c8fb8841b945067ce544188f5681
2013-11-27 01:05:17 +00:00

77 lines
1.5 KiB
Bash
Executable File

#!/bin/bash -e
GERRIT_SITE=$1
ZUUL_SITE=$2
GIT_ORIGIN=$3
if [ -z "$GERRIT_SITE" ]
then
echo "The gerrit site name (eg 'https://review.openstack.org') must be the first argument."
exit 1
fi
if [ -z "$ZUUL_SITE" ]
then
echo "The zuul site name (eg 'http://zuul.openstack.org') must be the second argument."
exit 1
fi
if [ -z "$GIT_ORIGIN" ] || [ -n "$ZUUL_NEWREV" ]
then
GIT_ORIGIN="$GERRIT_SITE/p"
# git://git.openstack.org/
# https://review.openstack.org/p
fi
if [ -z "$ZUUL_REF" ]
then
echo "This job may only be triggered by Zuul."
exit 1
fi
if [ ! -z "$ZUUL_CHANGE" ]
then
echo "Triggered by: $GERRIT_SITE/$ZUUL_CHANGE"
fi
set -x
if [[ ! -e .git ]]
then
ls -a
rm -fr .[^.]* *
git clone $GIT_ORIGIN/$ZUUL_PROJECT .
fi
git remote set-url origin $GIT_ORIGIN/$ZUUL_PROJECT
# attempt to work around bugs 925790 and 1229352
if ! git remote update
then
echo "The remote update failed, so garbage collecting before trying again."
git gc
git remote update
fi
git reset --hard
if ! git clean -x -f -d -q ; then
sleep 1
git clean -x -f -d -q
fi
if [ -z "$ZUUL_NEWREV" ]
then
git fetch $ZUUL_SITE/p/$ZUUL_PROJECT $ZUUL_REF
git checkout FETCH_HEAD
git reset --hard FETCH_HEAD
if ! git clean -x -f -d -q ; then
sleep 1
git clean -x -f -d -q
fi
else
git checkout $ZUUL_NEWREV
git reset --hard $ZUUL_NEWREV
if ! git clean -x -f -d -q ; then
sleep 1
git clean -x -f -d -q
fi
fi