READMEs/README-watchers.md
Sai Watcher SystemThe Sai Watcher system allows the CI server to monitor external asynchronous services (like Coverity, SonarCloud, etc.) via periodic HTML screenscraping. This is useful for services that provide status updates at a public URL after a build or upload is completed. How it Works
ConfigurationWatchers are defined in JSON files located in Service Object Fields
Scraping Rule Fields ( |
| Field | Type | Description |
|---|---|---|
label | string | Key name for the extracted value in the metrics JSON. |
prefix | string | HTML string immediately preceding the value. |
suffix | string | HTML string immediately following the value. |
anchor | string | (Optional) HTML string to find first before looking for the prefix. |
final | boolean | If this rule matches, the watcher transitions to the FINISHED state and stops polling. |
UI Rule Fields (ui)
| Field | Type | Description |
|---|---|---|
label | string | Human-readable label displayed in the UI. |
key | string | The metric key (from rules.label) to display. |
warn_if_gt | number | (Optional) Value above which the metric is highlighted as a warning. |
fail_if_gt | number | (Optional) Value above which the metric is highlighted as a failure. |
Example: Coverity
To configure a watcher for Coverity, create a file like /etc/sai/server/conf.d/coverity.json:
{
"watchers": [
{
"name": "coverity",
"match": "scan.coverity.com/projects/",
"rules": [
{
"label": "status",
"prefix": "Last Build Status:</td><td>",
"suffix": "</td>"
},
{
"label": "density",
"prefix": "Defect Density:</td><td>",
"suffix": "</td>"
},
{
"label": "defects",
"prefix": "Outstanding Defects:</td><td>",
"suffix": "</td>"
},
{
"label": "passed",
"prefix": "Last Build Status:</td><td>Passed",
"suffix": "</td>",
"final": true
}
],
"ui": [
{
"label": "Status",
"key": "status"
},
{
"label": "Density",
"key": "density"
},
{
"label": "Defects",
"key": "defects",
"warn_if_gt": 0,
"fail_if_gt": 10
}
]
}
]
}
Triggering from .sai.json
In your task steps, after a successful upload, simply echo the status URL:
"steps": [
{
"name": "upload",
"run": "<upload commands> ... && echo \"SAI_WATCH_URL: https://scan.coverity.com/projects/my-project\""
}
]
Assets
Place a service icon at assets/watchers/<name>/icon.svg on the server to have it appear in the dashboard.