Include log tail in release failure notifications
This commit is contained in:
2 files changed
+31
No files matched your search
@@ -40,6 +40,8 @@ if [[ -n "$LOG_MIRROR" ]]; then
|
|||||||
else
|
else
|
||||||
LOG_FILE="$LOG_DIR/repo_${TIMESTAMP}.log"
|
LOG_FILE="$LOG_DIR/repo_${TIMESTAMP}.log"
|
||||||
fi
|
fi
|
||||||
|
export LOG_FILE
|
||||||
|
export OMARCHY_LOG_FILE="$LOG_FILE"
|
||||||
|
|
||||||
# Show usage
|
# Show usage
|
||||||
show_usage() {
|
show_usage() {
|
||||||
|
|||||||
@@ -19,15 +19,44 @@ notify_basecamp() {
|
|||||||
"$BASECAMP_CHATBOT_URL" 2>/dev/null || true
|
"$BASECAMP_CHATBOT_URL" 2>/dev/null || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
basecamp_html_escape() {
|
||||||
|
sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g'
|
||||||
|
}
|
||||||
|
|
||||||
|
basecamp_strip_ansi() {
|
||||||
|
sed -E $'s/\x1B\\[[0-9;?]*[ -/]*[@-~]//g'
|
||||||
|
}
|
||||||
|
|
||||||
|
basecamp_format_log_tail_html() {
|
||||||
|
local log_file="$1"
|
||||||
|
local lines="${2:-25}"
|
||||||
|
|
||||||
|
[[ -n "$log_file" && -f "$log_file" ]] || return 0
|
||||||
|
|
||||||
|
tail -n "$lines" "$log_file" 2>/dev/null |
|
||||||
|
tr -d '\r' |
|
||||||
|
basecamp_strip_ansi |
|
||||||
|
basecamp_html_escape |
|
||||||
|
sed ':a;N;$!ba;s/\n/<br>/g'
|
||||||
|
}
|
||||||
|
|
||||||
notify_error() {
|
notify_error() {
|
||||||
local title="$1"
|
local title="$1"
|
||||||
local details="${2:-}"
|
local details="${2:-}"
|
||||||
|
local log_file="${OMARCHY_LOG_FILE:-${LOG_FILE:-}}"
|
||||||
|
local log_tail_lines="${BASECAMP_LOG_TAIL_LINES:-25}"
|
||||||
|
local log_tail=""
|
||||||
|
|
||||||
local content="🔴 <strong>${title}</strong>"
|
local content="🔴 <strong>${title}</strong>"
|
||||||
if [[ -n "$details" ]]; then
|
if [[ -n "$details" ]]; then
|
||||||
content+="<br>${details}"
|
content+="<br>${details}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
log_tail=$(basecamp_format_log_tail_html "$log_file" "$log_tail_lines")
|
||||||
|
if [[ -n "$log_tail" ]]; then
|
||||||
|
content+="<br><br><strong>Last ${log_tail_lines} log lines:</strong><br><code>${log_tail}</code>"
|
||||||
|
fi
|
||||||
|
|
||||||
notify_basecamp "$content"
|
notify_basecamp "$content"
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user