summaryrefslogtreecommitdiff
path: root/jenkins.sh
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@linaro.org>2018-05-03 14:06:16 +0000
committerChristophe Lyon <christophe.lyon@linaro.org>2018-05-07 08:11:32 +0000
commit95beec124ec5f9bd95d88fd6c00ecd4a0e718dab (patch)
tree5bd85bd0c158539c432f9b495b6a79161963371e /jenkins.sh
parent027443b77e835e270e6e5325ec2d9feb343531c9 (diff)
jenkins-logs.sh: Upload logs during EXIT trap handler.
We upload the logs and results at the very end of the script, but in some cases we exit earlier (for instance when the first cross-compiler build failed). In such cases we wouldn't upload the logs, relying on the Jenkins artifacts to debug the problem. This patch moves the logs upload code to a dedicated function, which is called as the EXIT trap handler. Change-Id: I7106ff19d933bdf90b41cf7adb1c78e25f8bba3e
Diffstat (limited to 'jenkins.sh')
-rwxr-xr-xjenkins.sh65
1 files changed, 41 insertions, 24 deletions
diff --git a/jenkins.sh b/jenkins.sh
index 9f0e5328..f2f142a8 100755
--- a/jenkins.sh
+++ b/jenkins.sh
@@ -39,6 +39,36 @@ read_var()
grep "^${var}=" "${artifact_list}" | cut -d = -f 2-
}
+upload_to_logserver()
+{
+ logs_dir=$(mktemp -d)
+
+ # Copy over the build logs
+ makelog_list=($(read_var ${user_workspace}/build-artifacts.txt 'log_make_[^=]*'))
+ if test x"${canadian}" = x"true"; then
+ makelog_list+=($(read_var ${user_workspace}/canadian-build1-artifacts.txt 'log_make_[^=]*'))
+ makelog_list+=($(read_var ${user_workspace}/canadian-build2-artifacts.txt 'log_make_[^=]*'))
+ fi
+ for makelog in "${makelog_list[@]}"; do
+ cp ${makelog} ${logs_dir}/ || status=1
+ done
+
+ # Copy stdout and stderr output from abe.
+ cp build.out build.err ${logs_dir}/ || status=1
+ if $runtests; then
+ cp check.out check.err ${logs_dir}/ || status=1
+ fi
+
+ xz ${logs_dir}/* || status=1
+ scp $logopts ${logs_dir}/* ${logserver}:${basedir}/${dir}/ || status=1
+
+ rm -rf ${logs_dir} || status=1
+
+ echo "Uploaded build logs to ${logserver}:$logport:${basedir}/${dir}/ with status: $status"
+
+ exit $status
+}
+
if test $# -lt 1; then
echo "ERROR: No options for build!"
usage
@@ -351,6 +381,16 @@ fi
$CONFIG_SHELL ${abe_dir}/abe.sh ${platform} ${change} --checkout all
) 9>${git_reference}.lock
+# This creates the path on the remote file server and installs the
+# EXIT trap handler.
+if test x"${logserver}" != x""; then
+ # Re-eval $dir as we now have full range of variables available.
+ eval dir="$logname"
+ ssh $logopts ${logserver} mkdir -p ${basedir}/${dir}
+
+ trap "upload_to_logserver" EXIT
+fi
+
# Now we build the cross compiler, for a native compiler this becomes
# the stage2 bootstrap build.
ret=0
@@ -416,11 +456,7 @@ if test x"${manifest}" = x; then
echo "ERROR: No manifest file, build probably failed!"
fi
-# This becomes the path on the remote file server
if test x"${logserver}" != x""; then
- # Re-eval $dir as we now have full range of variables available.
- eval dir="$logname"
- ssh $logopts ${logserver} mkdir -p ${basedir}/${dir}
if test x"${manifest}" != x; then
scp $logopts ${manifest} ${logserver}:${basedir}/${dir}/
fi
@@ -480,28 +516,9 @@ if test x"${logserver}" != x"" && test x"${sums}" != x -o x"${runtests}" != x"tr
cp ${check} ${logs_dir}/ || status=1
done
fi
-
- # Copy over the build logs
- makelog_list=($(read_var ${user_workspace}/build-artifacts.txt 'log_make_[^=]*'))
- if test x"${canadian}" = x"true"; then
- makelog_list+=($(read_var ${user_workspace}/canadian-build1-artifacts.txt 'log_make_[^=]*'))
- makelog_list+=($(read_var ${user_workspace}/canadian-build2-artifacts.txt 'log_make_[^=]*'))
- fi
- for makelog in "${makelog_list[@]}"; do
- cp ${makelog} ${logs_dir}/ || status=1
- done
-
- # Copy stdout and stderr output from abe.
- cp build.out build.err ${logs_dir}/ || status=1
- if $runtests; then
- cp check.out check.err ${logs_dir}/ || status=1
- fi
-
- xz ${logs_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}:$logport:${basedir}/${dir}/ with status: $status"
+ echo "Uploaded test results to ${logserver}:$logport:${basedir}/${dir}/ with status: $status"
if test x"${tarsrc}" = xtrue -a x"${release}" != x; then
allfiles="$(ls ${user_snapshots}/*${release}*.xz)"