[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] djm: refactoring, djm-logparser now runs djm-jenkins-parser remotely first
Holger Levsen (@holger)
gitlab at salsa.debian.org
Mon Apr 10 18:41:40 BST 2023
Holger Levsen pushed to branch master at Debian QA / jenkins.debian.net
Commits:
4cf4e2c5 by Holger Levsen at 2023-04-10T19:40:32+02:00
djm: refactoring, djm-logparser now runs djm-jenkins-parser remotely first
Signed-off-by: Holger Levsen <holger at layer-acht.org>
- - - - -
2 changed files:
- bin/djm-jenkins-parser.sh
- bin/djm-logparser
Changes:
=====================================
bin/djm-jenkins-parser.sh
=====================================
@@ -1,13 +1,36 @@
#!/bin/bash
+# vim: set noexpandtab:
-cd ~/jobs
+#
+# djm - documented jenkins maintenance logparser for jenkin build logs
+#
+# Copyright 2023 Holger Levsen <holger at layer-acht.org>
+# released under the GPLv2
+#
-HUMAN=holger
+set -e
+set -o pipefail # see eg http://petereisentraut.blogspot.com/2010/11/pipefail.html
+
+# check environment
+if [ -z "$DJM_USER" ] ; then
+ echo "Environment variable DJM_USER must be set. Exiting."
+ exit 1
+fi
+if [ !-d ~jenkins/jobs ] ; then
+ echo "~jenkins/jobs is not a directory, are you running this on the jenkins host?"
+ exit 1
+fi
+cd ~jenkins/jobs
export TZ="/usr/share/zoneinfo/UTC"
MYLOG=~/.djm-jenkins-parser.log
MYRESULTS=~/.djm-jenkins-ui.log
+#
+# main
+#
+
+# find recent / unparsed logfiles
if [ ! -f $MYLOG ] ; then
LOGS=$(find ./reproducible_*/builds/*/log 2>/dev/null)
ZLOGS=$(find ./reproducible_*/builds/*/log.gz 2>/dev/null)
@@ -22,6 +45,7 @@ else
fi
echo "Parsing $(echo $LOGS $ZLOGS | sed 's# #\n#g' | wc -l) logfiles now."
+# find logfiles triggered by $DJM_USER and write correspondig djm logfile entries
(
for i in $LOGS $ZLOGS ; do
DIRNAME="$(dirname $i)"
@@ -30,9 +54,9 @@ for i in $LOGS $ZLOGS ; do
else
echo "$DIRNAME/log" >> $MYLOG
if [ "$(basename $i)" == "log" ] ; then
- RESULT=$(head -1 $i | grep -E -i "Started by user.*$HUMAN")
+ RESULT=$(head -1 $i | grep -E -i "Started by user.*$DJM_USER")
else
- RESULT=$(zcat $i | head -1 | grep -E -i "Started by user.*$HUMAN")
+ RESULT=$(zcat $i | head -1 | grep -E -i "Started by user.*$DJM_USER")
fi
if [ -n "$RESULT" ] ; then
: # echo $i
=====================================
bin/djm-logparser
=====================================
@@ -12,14 +12,26 @@ set -e
set -o pipefail # see eg http://petereisentraut.blogspot.com/2010/11/pipefail.html
#
-# define environment and parse parameters
+# define environment
#
-
+if [ -z "$DJM_USER" ] ; then
+ echo "Environment variable DJM_USER must be set. Exiting."
+ exit 1
+fi
LOCAL_LOGFILE=~/.djm.log
UI_LOGFILE=~/.djm-jenkins-ui.log
+LOGMONTH="$(date -u '+%Y-%m')"
+
+#
+# parse jenkins build logs and copy the result over
+#
+ssh $DJM_USER at jenkins.debian.net "DJM_USER=$DJM_USER /srv/jenkins/bin/djm-jenkins-parser"
+scp $DJM_USER at jenkins.debian.net:$UI_LOGFILE $UI_LOGFILE
+#
+# little helpers
+#
LOGFILE=$(mktemp)
-LOGMONTH="$(date -u '+%Y-%m')"
cat $LOCAL_LOGFILE $UI_LOGFILE | grep ^$LOGMONTH | sort -u > $LOGFILE
THREE_C="%42s %12s %12s\n"
TWO_C="%42s %12s\n"
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/4cf4e2c52a0d08ee7eb1ad9eaabca01ec82e5094
--
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/4cf4e2c52a0d08ee7eb1ad9eaabca01ec82e5094
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/20230410/a750220d/attachment-0001.htm>
More information about the Qa-jenkins-scm
mailing list