[FIX] add support agent github code

This commit is contained in:
goodrain 2018-02-23 12:34:35 +08:00
parent 4b02f58beb
commit f54d6e1970
2 changed files with 12 additions and 2 deletions

View File

@ -118,8 +118,10 @@ class RepoBuilder():
num = 0
while num < 2:
try:
shell.call("timeout -k 9 {2} git clone {0} {1}".format(
self.repo_url, self.source_dir, CLONE_TIMEOUT))
cmdstr = "timeout -k 9 {2} git clone {0} {1}".format(self.repo_url, self.source_dir, CLONE_TIMEOUT)
if "github.com" in self.repo_url:
cmdstr = "timeout -k 9 {2} git clone -c http.proxy=http://127.0.0.1:18888 {0} {1}".format(self.repo_url, self.source_dir, CLONE_TIMEOUT)
shell.call(cmdstr)
result = True
break
except shell.ExecException, e:

View File

@ -25,6 +25,7 @@ PROCFILE=""
# bin
JQBIN="$WORK_DIR/bin/jq"
GITBIN="/usr/bin/git clone -q"
GITBINC="/usr/bin/git clone -c http.proxy=http://127.0.0.1:18888 -q"
# path
SOURCE_DIR="/cache/build/${TENANT_ID}/source/${SERVICE_ID}"
@ -39,7 +40,14 @@ LIBDIR="$WORK_DIR/lib"
set -e
# 克隆代码
CLONE_TIMEOUT=180
if [[ $GITURL == *github.com* ]]
then
timeout -k 9 $CLONE_TIMEOUT $GITBINC $GITURL $SOURCE_DIR > /dev/null 2>&1
else
timeout -k 9 $CLONE_TIMEOUT $GITBIN $GITURL $SOURCE_DIR > /dev/null 2>&1
fi
if [ $? -eq 124 ];then
echo "timeout in $CLONE_TIMEOUT: $GITURL"
exit 1