This commit is contained in:
4
gitea-build-monitor-cache.json
Normal file
4
gitea-build-monitor-cache.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"zaine/org_roam:job:11:state:failure": "2026-05-06T16:53:51.9326232+01:00",
|
||||||
|
"zaine/org_roam:job:12:state:success": "2026-05-06T16:53:52.0266348+01:00"
|
||||||
|
}
|
||||||
@@ -1 +1,7 @@
|
|||||||
2026-05-06T16:46:05.3464989+01:00 [INFO] Validation mode completed: configuration and PowerShell runtime are valid.
|
2026-05-06T16:46:05.3464989+01:00 [INFO] Validation mode completed: configuration and PowerShell runtime are valid.
|
||||||
|
2026-05-06T16:53:51.6056726+01:00 [INFO] Fetching recent Gitea Actions jobs for zaine/org_roam.
|
||||||
|
2026-05-06T16:53:51.9371399+01:00 [INFO] Analyzed job 11 for zaine/org_roam: severity=Critical, status=failure, duration=28s
|
||||||
|
2026-05-06T16:53:52.0270575+01:00 [INFO] Analyzed job 12 for zaine/org_roam: severity=Critical, status=success, duration=29s
|
||||||
|
2026-05-06T16:53:52.6590363+01:00 [INFO] Sent Discord notification with 2 embed(s).
|
||||||
|
2026-05-06T16:54:40.3683000+01:00 [INFO] Fetching recent Gitea Actions jobs for zaine/org_roam.
|
||||||
|
2026-05-06T16:54:40.4943993+01:00 [INFO] No new jobs found in the last 30 minute(s).
|
||||||
|
|||||||
@@ -386,7 +386,7 @@ function Get-LogSummary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$matches = New-Object System.Collections.Generic.List[string]
|
$matchedLines = New-Object System.Collections.Generic.List[string]
|
||||||
$hasErrors = $false
|
$hasErrors = $false
|
||||||
$hasWarnings = $false
|
$hasWarnings = $false
|
||||||
|
|
||||||
@@ -414,13 +414,13 @@ function Get-LogSummary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($isError -or $isWarning) -and $matches.Count -lt 8) {
|
if (($isError -or $isWarning) -and $matchedLines.Count -lt 8) {
|
||||||
$matches.Add($trimmed)
|
$matchedLines.Add($trimmed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$summary = if ($matches.Count -gt 0) {
|
$summary = if ($matchedLines.Count -gt 0) {
|
||||||
($matches | Select-Object -First 8) -join "`n"
|
($matchedLines | Select-Object -First 8) -join "`n"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
'No matching warning or error lines found.'
|
'No matching warning or error lines found.'
|
||||||
@@ -572,22 +572,29 @@ function Send-DiscordNotification {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$chunks = for ($i = 0; $i -lt $alerting.Count; $i += [int]$Config.MaxDiscordEmbeds) {
|
$maxEmbeds = [int]$Config.MaxDiscordEmbeds
|
||||||
,($alerting[$i..([Math]::Min($i + [int]$Config.MaxDiscordEmbeds - 1, $alerting.Count - 1))])
|
if ($maxEmbeds -lt 1) {
|
||||||
|
$maxEmbeds = 1
|
||||||
}
|
}
|
||||||
|
for ($offset = 0; $offset -lt $alerting.Count; $offset += $maxEmbeds) {
|
||||||
foreach ($chunk in $chunks) {
|
$chunk = @($alerting | Select-Object -Skip $offset -First $maxEmbeds)
|
||||||
$criticalCount = @($chunk | Where-Object { $_.Severity -eq 'Critical' }).Count
|
$criticalCount = @($chunk | Where-Object { $_.Severity -eq 'Critical' }).Count
|
||||||
$warningCount = @($chunk | Where-Object { $_.Severity -eq 'Warning' }).Count
|
$warningCount = @($chunk | Where-Object { $_.Severity -eq 'Warning' }).Count
|
||||||
|
$embeds = @($chunk | ForEach-Object { New-DiscordEmbed -Analysis $_ })
|
||||||
$payload = @{
|
$payload = @{
|
||||||
username = 'Gitea Build Monitor'
|
username = 'Gitea Build Monitor'
|
||||||
content = if ($criticalCount -gt 0) { "❌ Gitea build monitor found $criticalCount critical issue(s) and $warningCount warning(s)." } else { "⚠️ Gitea build monitor found $warningCount warning(s)." }
|
content = if ($criticalCount -gt 0) { "❌ Gitea build monitor found $criticalCount critical issue(s) and $warningCount warning(s)." } else { "⚠️ Gitea build monitor found $warningCount warning(s)." }
|
||||||
embeds = @($chunk | ForEach-Object { New-DiscordEmbed -Analysis $_ })
|
embeds = $embeds
|
||||||
}
|
}
|
||||||
|
|
||||||
Invoke-DiscordWebhook -Payload $payload
|
Invoke-DiscordWebhook -Payload $payload
|
||||||
|
if ($DryRun) {
|
||||||
|
Write-Log -Message "Prepared Discord notification with $($chunk.Count) embed(s) in dry-run mode."
|
||||||
|
}
|
||||||
|
else {
|
||||||
Write-Log -Message "Sent Discord notification with $($chunk.Count) embed(s)."
|
Write-Log -Message "Sent Discord notification with $($chunk.Count) embed(s)."
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Test-IsRecentBuild {
|
function Test-IsRecentBuild {
|
||||||
@@ -673,7 +680,7 @@ function Start-BuildMonitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($analyses.Count -gt 0) {
|
if ($analyses.Count -gt 0) {
|
||||||
Send-DiscordNotification -Analyses @($analyses)
|
Send-DiscordNotification -Analyses $analyses.ToArray()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Log -Message "No new jobs found in the last $($Config.LookbackMinutes) minute(s)."
|
Write-Log -Message "No new jobs found in the last $($Config.LookbackMinutes) minute(s)."
|
||||||
@@ -689,5 +696,9 @@ try {
|
|||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Log -Level 'ERROR' -Message "Build monitor failed: $($_.Exception.Message)"
|
Write-Log -Level 'ERROR' -Message "Build monitor failed: $($_.Exception.Message)"
|
||||||
|
Write-Log -Level 'ERROR' -Message "Exception type: $($_.Exception.GetType().FullName)"
|
||||||
|
if ($_.ScriptStackTrace) {
|
||||||
|
Write-Log -Level 'ERROR' -Message "Stack trace: $($_.ScriptStackTrace)"
|
||||||
|
}
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user