summaryrefslogtreecommitdiff
path: root/jenkins.sh
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2017-06-15 12:16:52 +0000
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2017-06-15 12:18:04 +0000
commit02930a1279abbf052a0dfcaab09955d7bbdf3b76 (patch)
tree4d40f57fcc8bb024ec28d2cc8a5499d291671fe6 /jenkins.sh
parent561c60e6ce4309f1b523a00b276b30e9ec97e36a (diff)
jenkins.sh: Support logserver on non-default ssh ports
To switch to dedicated log-providing ssh server running inside a container. Change-Id: I584ff754dfb3cf075625dfaad70e048bed4c3bdc
Diffstat (limited to 'jenkins.sh')
-rwxr-xr-xjenkins.sh35
1 files changed, 20 insertions, 15 deletions
diff --git a/jenkins.sh b/jenkins.sh
index 51368baf..06c34ad3 100755
--- a/jenkins.sh
+++ b/jenkins.sh
@@ -149,22 +149,27 @@ fi
# Now that all variables from $logname template are known, calculate log dir.
eval dir="$logname"
-# Split $logserver into "server:path".
-basedir="${logserver#*:}"
-logserver="${logserver%:*}"
+# Split $logserver into "server:port:path".
+basedir="${logserver##*:}"
+logserver_spec="${logserver%:*}"
+
+logserver="$(echo $logserver_spec | cut -d: -f 1)"
+logport="$(echo $logserver_spec | cut -s -d: -f 2)"
+
+logopts="${logport:+-o Port=$logport}"
# Check status of logs on $logserver and rebuild if appropriate.
-[ x"$logserver" != x"" ] && ssh $logserver mkdir -p $(dirname $basedir/$dir)
+[ x"$logserver" != x"" ] && ssh $logopts $logserver mkdir -p $(dirname $basedir/$dir)
# Loop and wait until we successfully grabbed the lock. The while condition is,
# effectively, "while true;" with a provision to skip if $logserver is not set.
while [ x"$logserver" != x"" ]; do
# Non-blocking read lock, and check whether logs already exist.
- log_status=$(ssh $logserver flock -ns $basedir/$dir.lock -c \
+ log_status=$(ssh $logopts $logserver flock -ns $basedir/$dir.lock -c \
"\"if [ -e $basedir/$dir ]; then exit 0; else exit 2; fi\""; echo $?)
case $log_status in
0)
- echo "Logs are already present in $logserver:$basedir/$dir"
+ echo "Logs are already present in $logserver:$logport:$basedir/$dir"
if ! $rebuild; then
exit 0
fi
@@ -199,7 +204,7 @@ while [ x"$logserver" != x"" ]; do
# any subsequent builds to progress. There are a couple of options as to
# exactly how enable delivery of SIGHUP (e.g., set +m), and 'ssh -tt' seems
# like the simplest one.
- ssh -tt $logserver flock -nx $basedir/$dir.lock -c \
+ ssh -tt $logopts $logserver flock -nx $basedir/$dir.lock -c \
"\"echo $(hostname)-$$-$BUILD_URL > $basedir/$dir.lock; while [ -e $basedir/$dir.lock ]; do sleep 10; done\"" &
pid=$!
# This is borderline fragile, since we are giving the above ssh command
@@ -209,9 +214,9 @@ while [ x"$logserver" != x"" ]; do
# just retry a couple of times in this loop.
sleep 10
- if [ x"$(ssh $logserver cat $basedir/$dir.lock)" \
+ if [ x"$(ssh $logopts $logserver cat $basedir/$dir.lock)" \
= x"$(hostname)-$$-$BUILD_URL" ]; then
- trap "ssh $logserver rm -f $basedir/$dir.lock" 0 1 2 3 5 9 13 15
+ trap "ssh $logopts $logserver rm -f $basedir/$dir.lock" 0 1 2 3 5 9 13 15
# Hurray! Break from the loop and go ahead with the build!
break
fi
@@ -414,9 +419,9 @@ fi
if test x"${logserver}" != x""; then
# Re-eval $dir as we now have full range of variables available.
eval dir="$logname"
- ssh ${logserver} mkdir -p ${basedir}/${dir}
+ ssh $logopts ${logserver} mkdir -p ${basedir}/${dir}
if test x"${manifest}" != x; then
- scp ${manifest} ${logserver}:${basedir}/${dir}/
+ scp $logopts ${manifest} ${logserver}:${basedir}/${dir}/
fi
# If 'make check' works, we get .sum files with the results. These we
@@ -492,22 +497,22 @@ if test x"${logserver}" != x"" && test x"${sums}" != x -o x"${runtests}" != x"tr
fi
xz ${logs_dir}/* || status=1
- scp ${logs_dir}/* ${logserver}:${basedir}/${dir}/ || status=1
+ scp $logopts ${logs_dir}/* ${logserver}:${basedir}/${dir}/ || status=1
rm -rf ${logs_dir} || status=1
- echo "Uploaded test results and build logs to ${logserver}:${basedir}/${dir}/ with status: $status"
+ echo "Uploaded test results and build logs to ${logserver}:$logport:${basedir}/${dir}/ with status: $status"
if test x"${tarsrc}" = xtrue -a x"${release}" != x; then
allfiles="$(ls ${user_snapshots}/*${release}*.xz)"
srcfiles="$(echo ${allfiles} | egrep -v "arm|aarch")"
- scp ${srcfiles} ${logserver}:/home/abe/var/snapshots/ || status=1
+ scp $logopts ${srcfiles} ${logserver}:/home/abe/var/snapshots/ || status=1
rm -f ${srcfiles} || status=1
fi
if test x"${tarbin}" = xtrue -a x"${release}" != x; then
allfiles="$(ls ${user_snapshots}/*${release}*.xz)"
binfiles="$(echo ${allfiles} | egrep "arm|aarch")"
- scp ${binfiles} ${logserver}:/work/space/binaries/ || status=1
+ scp $logopts ${binfiles} ${logserver}:/work/space/binaries/ || status=1
rm -f ${binfiles} || status=1
fi