~sircmpwn/builds.sr.ht#313: 
feature: api: query jobs by tag

Currently, builds.sr.ht advertises a build badge which show a "build status" (via SVG) for a given tag. The value is based on the status of the most recent non-cancelled job that contains that tag.

It would be helpful to have a way to query for this same information, directly, via the API.

As a workaround, one can query all of a user's jobs and filter based on its tags:

TOKEN="$(gopass ...)"
BUILD_HOST="https://build.sr.ht"
TAG="nixpkgs-wayland"
curl \
  -H "Authorization:token ${TOKEN}" \
  -H "Content-Type: application/json" -X GET \
  "${BUILD_HOST}/api/jobs" > /tmp/data
jq -r "[.results[] | select(.tags==\"${TAG}\" and .status!=\"running\")][0] | .status" /tmp/data

(note the example spits out just the status field, but otherwise would've returned the full job object)

Also, a note to document something else that tripped me up, the "tags" array that the API accepts is misleading, note that the order matters and forms a "path", as returned by the jobs api: the "tags" field is a string, not array. For example, if you specify tags:["tag1","tag2"] in the POST, you will get tags: "tag1/tag2" in the subsequent GET to query the job status.

Status
REPORTED
Submitter
~colemickens
Assigned to
No-one
Submitted
4 years ago
Updated
4 years ago
Labels
No labels applied.