Jenkins job monitoring is easy with Cronitor. By updating your build configuration to ping Cronitor
you'll gain visibility with a web dashboard and receive alerts of any noncompliance with the schedule, including:
- The job does not run when expected
- The job runs for longer than expected
Monitoring scheduled and automatically-triggered Jenkins jobs
Monitoring jenkins jobs is easy and requires no coding. Monitor job completion and duration by pinging Cronitor before and after your build step(s). First, we will create a new monitor for your Jenkins job.
- If this is a scheduled job, determine the frequency of the schedule, for example every 30 minutes. For jobs that are triggered automatically, choose a frequency that will avoid false-positives but still alert you promptly. For example, if your job is usually triggered every 15 minutes, consider a frequency of "1 hour".
- From your dashboard, click the button to create a new monitor and select Heartbeat
- Using the example of a job scheduled to run every 30 minutes, add a "Complete endpoint not pinged in 40 minutes" rule, padding the duration to avoid false positives.
Optionally, add a "Runs for longer than" rule to identify jobs that run longer than expected.
- Add at least one notification method across Email, SMS, Slack, Hipchat, PagerDuty, etc
- Give the monitor a descriptive name like Deploy API to Stage and add optional tags or notes
- Save the monitor and you will be given a unique ping URL.
Your new monitor is created in a paused state; monitoring will not begin until the first ping is received.
Integrating your Jenkins job monitor
By pinging Cronitor when your job runs we'll have the information needed to evaluate the rules you've created in your new monitor.
- Select the Jenkins job you wish to monitor and click configure.
- Find the Build Steps section and click Add Build Step
- Adapt the following Curl command using the unique ping URL code provided when you created your monitor. and paste into the Command textarea. Drag this in position as your first build step.
curl -Gm 5 https://cronitor.link/d3x0c1/run --data-urlencode "msg=$BUILD_DISPLAY_NAME"
- Repeat the process, pinging /complete, as the final build step. There is no need to pass the build name again.
curl -Gm 5 https://cronitor.link/d3x0c1/complete
- After saving, trigger a build manually to ensure that everything works as expected.