Jenkins + Sandglass: Heartbeat Monitoring for Jenkins Jobs

Jenkins jobs that silently stop running are a classic blind spot. Sandglass closes it.

Ping Sandglass from a Jenkins build so you know it ran on schedule. If the job stops executing, gets stuck in the queue, or fails before the ping step, Sandglass opens an incident.

Requirements

  • A Jenkins instance with at least one periodically triggered job (Build periodically or Pipeline cron)
  • The Jenkins agent or node running the job must have outbound HTTPS access to sandglass.it
  • curl available on the build agent (standard on Linux/macOS agents; use Invoke-WebRequest on Windows)
  • A Sandglass heartbeat check with its URL stored as a Jenkins credential or environment variable

How to connect

Step 1: Create a heartbeat check in Sandglass

Add a new Heartbeat check in Sandglass. Set the expected interval to match your Jenkins job schedule, adding a few minutes of buffer for queue wait time. Copy the heartbeat URL after saving.

Step 2: Store the heartbeat URL in Jenkins credentials

In Jenkins, go to Manage Jenkins > Credentials and add a new "Secret text" credential. Paste the heartbeat URL as the secret and give it an ID like SANDGLASS_HEARTBEAT_URL. Reference it in your pipeline with the credentials() binding so it never appears in console output.

Step 3: Add the heartbeat step to your pipeline or freestyle job

For a declarative pipeline, add a post { success { ... } } block with: "sh 'curl -fsS -m 10 --retry 3 \"$SANDGLASS_HEARTBEAT_URL\"' ". For a freestyle job, add an "Execute shell" build step at the end of the build with the same curl command. The post success block only fires when all stages pass, which is the right default.

Step 4: Trigger a manual build and verify

Run the job manually from the Jenkins dashboard. Open the console output and confirm the curl step ran and printed a 200 response. In Sandglass, the heartbeat check should flip to "Up" within seconds. If it stays pending, check that the agent can reach sandglass.it on port 443.

What you can do

  • Catch jobs that stop running: Jenkins does not alert you when a periodically triggered job stops executing. Sandglass does. Queue backlogs, executor shortages, or accidentally disabled triggers all look the same to Sandglass: a missing heartbeat means an incident.
  • Works with declarative and scripted pipelines: The heartbeat curl fits naturally into declarative pipeline post blocks, scripted pipeline try/finally blocks, and freestyle "Execute shell" steps. No Jenkins plugin required.
  • Supports Windows agents: On Windows build agents without curl, use PowerShell: "Invoke-WebRequest -Uri $env:SANDGLASS_HEARTBEAT_URL -Method POST -UseBasicParsing". The heartbeat endpoint accepts both GET and POST.
  • Explicit failure signaling: The /fail suffix on the heartbeat URL lets you open a Sandglass incident the moment a build fails, not just when the next scheduled run is missed. Combine success and failure post blocks for full coverage.

Frequently Asked Questions

Know when your Jenkins jobs stop running

Start free

Free plan, no credit card required.