I have a nightly Jenkins job with the "Restrict where this job can be run" job checked that ties it to build agents with specific labels. Recently, there were some issues where there were no build agents with that label, so the jobs didn't run at all. However, since the job didn't run, there was no email sent that it failed, so build failures didn't surface. Is there any way to get email notifications for Jenkins builds that don't run at all?
Asked
Active
Viewed 590 times
1
-
Jenkins does maintain a build history that can be inspected manually. Is that not sufficient? – rrirower Jan 14 '16 at 20:12
-
No, there's a lot of Jenkins jobs and I'd prefer to do as little babysitting as possible.. – Bill Prin Jan 14 '16 at 20:35
-
If the job gets triggered but no suitable executor, that should be in the "queue". – Jayan Jan 16 '16 at 11:31
1 Answers
0
Not currently, but there's a feature request.
My use case is similar to yours. I satisfied that use case by creating a job to monitor the build queue for stuck jobs The job runs periodically, every few minutes. If the queue is draining (that is no stuck jobs), the job succeeds. If the queue has at least one stuck job, the monitor job fails. When the monitor job fails, it sends a notification.
Here's how I implemented it. I'm using the queue API to pull JSON data:
#!/bin/bash
! curl -sS http://localhost/queue/api/json |\
jq '.items[] | select(.stuck == true) | .stuck' |\
grep -q 'true'
This grabs the build queue data (curl
), parses the JSON for those entries that are stuck (jq
), then matches those lines that are "true" (grep
). The exit code is inverted (!
), because I want the job to fail when there's a match and succeed when there's no match.