[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] fix a lot more cases dealing with undefined variables. again: thanks, josch

Holger Levsen gitlab at salsa.debian.org
Thu Nov 19 17:36:04 GMT 2020



Holger Levsen pushed to branch master at Debian QA / jenkins.debian.net


Commits:
e5d2db0b by Holger Levsen at 2020-11-19T18:35:48+01:00
fix a lot more cases dealing with undefined variables. again: thanks, josch

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -


1 changed file:

- bin/common-functions.sh


Changes:

=====================================
bin/common-functions.sh
=====================================
@@ -81,7 +81,7 @@ if [ "${0:0:5}" != "/tmp/" ] ; then
 	esac
 	# mktemp some place for us...
 	TTT=$(mktemp --tmpdir=/tmp jenkins-script-XXXXXXXX)
-	if [ -z "$TTT" ] ; then
+	if [ "${TTT+x}" != "x" ] ; then
 		echo "Failed to create tmpfile, aborting. (Probably due to read-only filesystem…)"
 		exit 1
 	fi
@@ -107,11 +107,11 @@ else
 	# this directory resides on tmpfs, so it might be gone after reboots...
 	mkdir -p /srv/workspace/chroots
 	# default settings used for the jenkins.debian.net environment
-	if [ -z "$LC_ALL" ]; then
+	if [ "${LC_ALL+x}" != "x" ] ; then
 		export LC_ALL=C.UTF-8
 	fi
 
-	if [ -z "$MIRROR" ]; then
+	if [ "${MIRROR+x}" != "x" ] ; then
 		case $HOSTNAME in
 			jenkins|jenkins-test-vm|ionos*|osuosl*)
 				export MIRROR=http://cdn-fastly.deb.debian.org/debian ;;
@@ -146,10 +146,10 @@ else
 		*)
 			echo "unsupported host, exiting." ; exit 1 ;;
 	esac
-	if [ -z "$CHROOT_BASE" ]; then
+	if [ "${CHROOT_BASE+x}" != "x" ] ; then
 		export CHROOT_BASE=/chroots
 	fi
-	if [ -z "$SCHROOT_BASE" ]; then
+	if [ "${SCHROOT_BASE+x}" != "x" ] ; then
 		export SCHROOT_BASE=/schroots
 	fi
 	if [ ! -d "$SCHROOT_BASE" ]; then
@@ -180,7 +180,8 @@ publish_changes_to_userContent() {
 	CHANGES=$1
 	CHANNEL=$2
 	SRCPKG=$(basename $CHANGES | cut -d "_" -f1)
-	if [ -z "$SRCPKG" ] ; then
+	if [ "${SRCPKG+x}" != "x" ] ; then
+		echo '$SRCPKG is empty, exiting with error.'
 		exit 1
 	fi
 	VERSION=$(basename $CHANGES | cut -d "_" -f2)
@@ -193,7 +194,7 @@ publish_changes_to_userContent() {
 	mkdir $TARGET
 	mv ${NEW_CONTENT}/usr/share/doc/${SRCPKG}* $TARGET/
 	rm -r ${NEW_CONTENT}
-	if [ -z "$3" ] ; then
+	if [ "${3+x}" != "x" ] ; then
 		touch "$TARGET/${VERSION}"
 		FROM=""
 	else
@@ -204,7 +205,7 @@ publish_changes_to_userContent() {
 	echo
 	echo $MESSAGE
 	echo
-	if [ ! -z "$CHANNEL" ] ; then
+	if [ "${CHANNEL+x}" = "x" ] ; then
 		kgb-client --conf /srv/jenkins/kgb/$CHANNEL.conf --relay-msg "$MESSAGE"
 	fi
 }
@@ -220,7 +221,7 @@ jenkins_zombie_check() {
 	# so just report those zombies here.
 	#
 	ZOMBIES=$(ls -1d /var/lib/jenkins/jobs/* | egrep 'strip-nondeterminism|reprotest|reproducible_(builder_(amd64|i386|armhf|arm64)|setup_(pbuilder|schroot)_testing)|chroot-installation_wheezy|aptdpkg|reproducible_*(odc2a|odxu4c|opi2b)|stretch_install_education-thin-client-server|jessie_multiarch_versionskew|dpkg_stretch_find_trigger_cycles|sid_install_education-services|buster_install_education-services|lvc|chroot-installation_stretch_.*_upgrade_to_sid|piuparts_.*_jessie|udd_stretch|d-i_pu-build|debsums-tests_stretch|debian-archive-keyring-tests_stretch|chroot-installation_jessie|chroot-installation_.*education-lang-|kirkwoot|rebootstrap_.*_gcc[5-8]($|_)|brcm47xx|rebootstrap_kfreebsd|diffoscope_from_git_|disorderfs_from_git_master|diffoscope_pypi|diffoscope_freebsd|diffoscope_netbsd|diffoscope_macports|diffoscope_archlinux|openwrt-target-ath97|profitbricks' || true)
-	if [ ! -z "$ZOMBIES" ] ; then
+	if [ "${ZOMBIES+x}" = "x" ] ; then
 		DIRTY=true
 		figlet 'zombies!!!'
 		echo "Warning, rise of the jenkins job zombies has started again, these jobs should not exist:"
@@ -237,13 +238,13 @@ jenkins_logsize_check() {
 	# /var/log/jenkins/jenkins.log sometimes grows very fast
 	# and we don't yet know why, so let's monitor this for now.
 	JENKINSLOG="$(find /var/log/jenkins -name jenkins.log -size +42G)"
-	if [ -z "JENKINSLOG" ] ; then
+	if [ "${JENKINSLOG+x}" != "x" ] ; then
 		figlet 'jenkins.log size'
 		echo "Warning, jenkins.log is larger than 42G, please fix, erroring out now."
 		exit 1
 	else
 		JENKINSLOG="$(find /var/log/jenkins -name jenkins.log -size +23G)"
-		if [ -z "JENKINSLOG" ] ; then
+		if [ "${JENKINSLOG+x}" != "x" ] ; then
 			DIRTY=true
 			figlet 'jenkins.log size'
 			echo "Warning, jenkins.log is larger than 23G, please do something…"



View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/e5d2db0b506f7928cda1e37ce6aaa437119334e0

-- 
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/e5d2db0b506f7928cda1e37ce6aaa437119334e0
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/qa-jenkins-scm/attachments/20201119/977f829a/attachment-0001.html>


More information about the Qa-jenkins-scm mailing list