@plot-pm/board 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/board-server.mjs +214 -207
- package/package.json +2 -1
- package/plot-approve.sh +9 -978
- package/plot-config.sh +8 -0
- package/plot-fleet-scan.sh +2 -2
- package/plot-host.sh +194 -110
- package/plot-reap.sh +12 -1250
package/plot-config.sh
CHANGED
|
@@ -193,6 +193,14 @@
|
|
|
193
193
|
# CI jenkins | github-actions | none — which CI system this
|
|
194
194
|
# project uses. Recorded by /plot-board-setup; not yet
|
|
195
195
|
# read by the board.
|
|
196
|
+
# Default branch checks
|
|
197
|
+
# comma-separated workflow names whose runs decide whether
|
|
198
|
+
# the default branch is red (`CI, Lint`). Read by fleetd
|
|
199
|
+
# where it writes `.plot/state/default-branch.json`; a run
|
|
200
|
+
# of any other workflow is not folded, so a publishing or
|
|
201
|
+
# release workflow cannot raise the `default-branch-red`
|
|
202
|
+
# hold or the board's red-branch status. Names match a run's
|
|
203
|
+
# workflow name exactly. Absent = every workflow's runs.
|
|
196
204
|
# Jenkins instance the slug or URL passed to a Jenkins CLI's -I flag.
|
|
197
205
|
# Read back by /plot-board-setup to verify auth against
|
|
198
206
|
# the right instance — without it the only runnable
|
package/plot-fleet-scan.sh
CHANGED
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
# every run.
|
|
221
221
|
#
|
|
222
222
|
# 2. `.plot/state/last-pulse.json` — the bridge, written by `write_bridge` on
|
|
223
|
-
# the success path of `--stream` (
|
|
223
|
+
# the success path of `--stream` (unless PLOT_SCAN_RECORD=0) and `--log-pulse`
|
|
224
224
|
# (what /plot-pulse passes). Those are the two callers that produce a pulse
|
|
225
225
|
# for somebody to READ; plain `--json` is a query and records nothing. That
|
|
226
226
|
# is a CACHE WITH AN EXPIRY: `pulse-bridge.ts` discards it after 15 minutes
|
|
@@ -311,7 +311,7 @@ while [ $# -gt 0 ]; do
|
|
|
311
311
|
# caught this: `conflicts: the scan writes NOTHING` and `fleet: scan is
|
|
312
312
|
# read-only`, both of which drive `--json`.
|
|
313
313
|
--json) as_json=1; build_doc=1 ;;
|
|
314
|
-
--stream) as_json=1; stream=1; build_doc=1; record=1 ;;
|
|
314
|
+
--stream) as_json=1; stream=1; build_doc=1; [ "${PLOT_SCAN_RECORD:-1}" = 0 ] || record=1 ;;
|
|
315
315
|
-h|--help) sed -n '2,12p' "$0"; exit 0 ;;
|
|
316
316
|
*) slug="$1" ;;
|
|
317
317
|
esac
|
package/plot-host.sh
CHANGED
|
@@ -66,9 +66,17 @@
|
|
|
66
66
|
# EXIT 3 is the question failing, and it is not
|
|
67
67
|
# the same as an empty answer: a diff that could
|
|
68
68
|
# not be read is not a diff that was empty.
|
|
69
|
+
# pr-merged-heads <branch> the head commit of every MERGED PR for this
|
|
70
|
+
# branch, one sha per line, or EMPTY (exit 0)
|
|
71
|
+
# where none merged. Reads `mergedAt`, never
|
|
72
|
+
# `state`. EXIT 3 is the question failing,
|
|
73
|
+
# including a CLI that fails without a word: an
|
|
74
|
+
# empty answer sends the reaper to a weaker
|
|
75
|
+
# reading, so only a recognised lookup miss is
|
|
76
|
+
# empty.
|
|
69
77
|
# pr-create --title T [--body B] [--base BR] [--head BR] [--draft]
|
|
70
78
|
# create a PR, print its URL
|
|
71
|
-
# pr-merge <number> [--squash] [--delete-branch]
|
|
79
|
+
# pr-merge <number> [--squash] [--delete-branch] [--match-head <sha>]
|
|
72
80
|
# pr-ready <number> take a PR out of draft
|
|
73
81
|
# merge the PR
|
|
74
82
|
# pr-list [--state open|merged|closed|all] [--limit N] [--rich|--rich-open]
|
|
@@ -448,6 +456,17 @@ die() { echo "plot-host: $*" >&2; exit 1; }
|
|
|
448
456
|
# error a person must fix, not a transient the board should retry past.
|
|
449
457
|
die3() { echo "plot-host: $*" >&2; exit 3; }
|
|
450
458
|
|
|
459
|
+
# THE ONE FOLD of a PR's check rollup into a word. `pr-list` and `pr-state` both
|
|
460
|
+
# read it, so what `green` means cannot differ between a listing and a merge.
|
|
461
|
+
# An allow-list: `ck` reads `ok` only for a finished item with an accepted
|
|
462
|
+
# result, `wait` for an unfinished one, and `bad` for every other word.
|
|
463
|
+
CHECKS_OF='def ck: (.conclusion // "") as $k | (.status // "") as $s | (if $s != "" then $s else (.state // "") end) as $w |
|
|
464
|
+
if $k != "" and ($s|IN("","COMPLETED")) then (if ($k|IN("SUCCESS","NEUTRAL","SKIPPED")) then "ok" else "bad" end)
|
|
465
|
+
elif ($w|IN("","QUEUED","IN_PROGRESS","WAITING","REQUESTED","PENDING","EXPECTED")) then "wait"
|
|
466
|
+
elif $s == "" and $w == "SUCCESS" then "ok" else "bad" end;
|
|
467
|
+
def checks_of: if (.statusCheckRollup|length) == 0 then "none" elif any(.statusCheckRollup[]; ck == "bad") then "failing"
|
|
468
|
+
elif any(.statusCheckRollup[]; ck == "wait") then "pending" else "green" end;'
|
|
469
|
+
|
|
451
470
|
# Exit 5 — the host refused to answer FOR NOW. A rate limit, primary or
|
|
452
471
|
# secondary: nothing is broken, nothing needs fixing, and the same question
|
|
453
472
|
# asked later will be answered.
|
|
@@ -1657,6 +1676,74 @@ jenkins_job_url_path() { # $1 = job path, $2 = branch or ""
|
|
|
1657
1676
|
printf '%s' "$out"
|
|
1658
1677
|
}
|
|
1659
1678
|
|
|
1679
|
+
# Every Jenkins build of one job that built ONE sha, as a JSON array (newest
|
|
1680
|
+
# first), or exit 3 (no instance) / exit 4 (cannot be asked). Shared by
|
|
1681
|
+
# `run-for-sha` and `runs-for-sha`, so the instance, the credential and the
|
|
1682
|
+
# multibranch-then-plain URL fallback are written once.
|
|
1683
|
+
#
|
|
1684
|
+
# $1 = the op's name, $2 = branch, $3 = how many builds to list, $4 = the sha.
|
|
1685
|
+
# Run it in `$(...)` and read the exit code with `|| exit $?`: it exits rather
|
|
1686
|
+
# than returns, and a subshell's exit is the code the caller sees.
|
|
1687
|
+
#
|
|
1688
|
+
# THE SHA IS IN JENKINS AND `jen` IS NOT THE TRANSPORT. Measured 2026-09-10: a
|
|
1689
|
+
# `jen build list --json` entry carries no sha, so Jenkins' REST API answers it
|
|
1690
|
+
# at `actions[].lastBuiltRevision.SHA1`. One `tree=` query returns a whole
|
|
1691
|
+
# history, so this costs one round trip like the GitHub arm.
|
|
1692
|
+
#
|
|
1693
|
+
# A BRANCH IS A JOB SEGMENT ON A MULTIBRANCH JOB AND NOT ON A PLAIN ONE, and no
|
|
1694
|
+
# reading of the configured path says which this is. The multibranch URL is
|
|
1695
|
+
# tried first and the plain one is the fallback (measured 2026-09-11: asking
|
|
1696
|
+
# the plain job for a branch segment answers 404). THE PLAIN JOB REPORTS ITS
|
|
1697
|
+
# OWN BUILDS whatever branch was asked about; the `sha` says which it built.
|
|
1698
|
+
#
|
|
1699
|
+
# NO CREDENTIAL IS *CANNOT BE ASKED*, never *no run*: the keychain is macOS-only
|
|
1700
|
+
# and a Linux agent legitimately has none. AN UNREACHABLE INSTANCE IS NOT AN
|
|
1701
|
+
# EMPTY HISTORY: a refused or redirected request answers HTML, which fails the
|
|
1702
|
+
# `builds` test.
|
|
1703
|
+
#
|
|
1704
|
+
# ONLY THE ASKED-FOR SHA, never another build's. `result` is null while a build
|
|
1705
|
+
# runs, Jenkins' own word for *in flight*, mapped to the `status`/`conclusion`
|
|
1706
|
+
# split the contract already uses so the shape does not fork per connector.
|
|
1707
|
+
jenkins_sha_runs() {
|
|
1708
|
+
local op="$1" branch="$2" limit="$3" sha="$4" instance host job cred tree body try path
|
|
1709
|
+
instance="$(jenkins_instance)"
|
|
1710
|
+
[ -n "$instance" ] || jenkins_no_instance
|
|
1711
|
+
host="${instance%%/*}"
|
|
1712
|
+
job="${instance#*/}"
|
|
1713
|
+
[ "$job" = "$instance" ] && job=""
|
|
1714
|
+
[ -n "${PLOT_JENKINS_JOB:-}" ] && job="$PLOT_JENKINS_JOB"
|
|
1715
|
+
if [ -z "$job" ]; then
|
|
1716
|
+
echo "plot-host: $op — the Jenkins instance names no job path; a sha lives in a job's builds, so it must be <slug>/<job/path>, not a bare host" >&2
|
|
1717
|
+
exit 4
|
|
1718
|
+
fi
|
|
1719
|
+
cred="$(jenkins_rest_credential "$host")" || {
|
|
1720
|
+
echo "plot-host: $op — no Jenkins API credential for '$host'" >&2
|
|
1721
|
+
echo " Jenkins' REST API takes basic auth with an API token, which \`jen auth login\` stores in the login keychain. The Keycloak bearer from \`jen auth token\` is NOT it." >&2
|
|
1722
|
+
exit 4
|
|
1723
|
+
}
|
|
1724
|
+
tree="tree=builds%5Bnumber,result,building,timestamp,url,actions%5BlastBuiltRevision%5BSHA1%5D%5D%5D%7B0,$limit%7D"
|
|
1725
|
+
body=""
|
|
1726
|
+
for path in "$(jenkins_job_url_path "$job" "$branch")" "$(jenkins_job_url_path "$job" "")"; do
|
|
1727
|
+
host_slot_take jenkins ''
|
|
1728
|
+
try=$(curl -sg --max-time 30 -u "$cred" "https://$host$path/api/json?$tree" 2>/dev/null) || true
|
|
1729
|
+
host_slot_give; budget_record_call jenkins ''
|
|
1730
|
+
if printf '%s' "$try" | jq -e 'has("builds")' >/dev/null 2>&1; then body="$try"; break; fi
|
|
1731
|
+
done
|
|
1732
|
+
cred=""
|
|
1733
|
+
if [ -z "$body" ]; then
|
|
1734
|
+
echo "plot-host: $op — Jenkins did not answer for '$host'" >&2
|
|
1735
|
+
exit 4
|
|
1736
|
+
fi
|
|
1737
|
+
printf '%s' "$body" | jq -c --arg sha "$sha" '
|
|
1738
|
+
[ .builds[]
|
|
1739
|
+
| { sha: ([ .actions[]? | select(.lastBuiltRevision) | .lastBuiltRevision.SHA1 ] | first // ""),
|
|
1740
|
+
status: (if .building then "in_progress" else "completed" end),
|
|
1741
|
+
conclusion: (if .building then null else (.result // null) end),
|
|
1742
|
+
url: (.url // ""),
|
|
1743
|
+
startedAt: (if .timestamp then (.timestamp / 1000 | todate) else "" end) } ]
|
|
1744
|
+
| map(select(.sha == $sha))' || exit 4
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1660
1747
|
ci_unaskable() { # $1 = the op's name, $2 = the CI word (may be empty)
|
|
1661
1748
|
local ci_word="${2:-}"
|
|
1662
1749
|
if [ -z "$ci_word" ] || [ "$ci_word" = none ]; then
|
|
@@ -1993,7 +2080,7 @@ rest_pr_to_state() {
|
|
|
1993
2080
|
state: $state,
|
|
1994
2081
|
draft: (.draft // false),
|
|
1995
2082
|
url: (.html_url // ""),
|
|
1996
|
-
mergeCommit: (.merge_commit_sha // "") }
|
|
2083
|
+
mergeCommit: (.merge_commit_sha // ""), headSha: (.head.sha // ""), checks: "unknown" }
|
|
1997
2084
|
'
|
|
1998
2085
|
}
|
|
1999
2086
|
|
|
@@ -3485,9 +3572,9 @@ case "$op" in
|
|
|
3485
3572
|
# mergeCommit is what lets a caller ask "which release contains this?" —
|
|
3486
3573
|
# `git tag --contains <sha>` answers exactly, where dates cannot. It is ""
|
|
3487
3574
|
# for anything unmerged, which is the honest answer rather than a guess.
|
|
3488
|
-
elif out="$(gh ${repo_args[@]+"${repo_args[@]}"} pr view "$ref" --json number,state,isDraft,url,mergeCommit 2>"$HOST_ERR")"; then
|
|
3575
|
+
elif out="$(gh ${repo_args[@]+"${repo_args[@]}"} pr view "$ref" --json number,state,isDraft,url,mergeCommit,headRefOid,statusCheckRollup 2>"$HOST_ERR")"; then
|
|
3489
3576
|
rm -f "$HOST_ERR"
|
|
3490
|
-
jq -c '{number:.number,state:.state,draft:.isDraft,url:.url,mergeCommit:(.mergeCommit.oid // "")}' <<<"$out"
|
|
3577
|
+
jq -c "$CHECKS_OF"'{number:.number,state:.state,draft:.isDraft,url:.url,mergeCommit:(.mergeCommit.oid // ""),headSha:(.headRefOid // ""),checks:checks_of,checksSha:(.headRefOid // "")}' <<<"$out"
|
|
3491
3578
|
else
|
|
3492
3579
|
err="$(cat "$HOST_ERR" 2>/dev/null)"; rm -f "$HOST_ERR"
|
|
3493
3580
|
# REFUSED FOR RATE IS NOT ANSWERED. The budget gate above could not see
|
|
@@ -3723,6 +3810,56 @@ case "$op" in
|
|
|
3723
3810
|
fi
|
|
3724
3811
|
;;
|
|
3725
3812
|
|
|
3813
|
+
pr-merged-heads)
|
|
3814
|
+
# THE HEAD COMMIT OF EVERY MERGED PR FOR A BRANCH, one sha per line.
|
|
3815
|
+
# `plot-reap.mjs` asks it only for a branch already known merged, to tell a
|
|
3816
|
+
# pushed commit from one made after the merge once the remote ref is gone.
|
|
3817
|
+
#
|
|
3818
|
+
# `--state all` and `--limit 100` for `pr-merged`'s own two reasons: a
|
|
3819
|
+
# merged PR reports CLOSED, and the newest PR is not the merge.
|
|
3820
|
+
#
|
|
3821
|
+
# A FAILURE WITH NO MESSAGE IS A FAILURE HERE, unlike `pr-state`: an empty
|
|
3822
|
+
# answer makes the caller fall back to a patch-id reading, so silence must
|
|
3823
|
+
# not stand in for *no merged head*. Only a recognised lookup miss is empty.
|
|
3824
|
+
ref="${1:?pr-merged-heads needs a branch}"; shift || true
|
|
3825
|
+
repo_args=()
|
|
3826
|
+
while [ $# -gt 0 ]; do
|
|
3827
|
+
case "$1" in
|
|
3828
|
+
--repo) repo_args=(-R "${2:?}"); shift 2 ;;
|
|
3829
|
+
*) die "pr-merged-heads: unknown arg $1" ;;
|
|
3830
|
+
esac
|
|
3831
|
+
done
|
|
3832
|
+
if [ "$be" = "github" ]; then
|
|
3833
|
+
if out="$(gh ${repo_args[@]+"${repo_args[@]}"} pr list --head "$ref" --state all --limit 100 --json mergedAt,headRefOid 2>"$HOST_ERR")"; then
|
|
3834
|
+
rm -f "$HOST_ERR"
|
|
3835
|
+
jq -r '.[] | select(.mergedAt != null and .headRefOid != null) | .headRefOid' <<<"$out" || exit 3
|
|
3836
|
+
else
|
|
3837
|
+
err="$(cat "$HOST_ERR" 2>/dev/null)"; rm -f "$HOST_ERR"
|
|
3838
|
+
if [ -n "$err" ] && is_lookup_miss "$err"; then
|
|
3839
|
+
:
|
|
3840
|
+
else
|
|
3841
|
+
echo "plot-host: ${err:-gh pr list failed}" >&2
|
|
3842
|
+
exit 3
|
|
3843
|
+
fi
|
|
3844
|
+
fi
|
|
3845
|
+
else
|
|
3846
|
+
bb_require_json
|
|
3847
|
+
# Bitbucket names the merged head `source.commit.hash`.
|
|
3848
|
+
if out="$(bb ${repo_args[@]+"${repo_args[@]}"} pr list --state merged --json 2>"$HOST_ERR")"; then
|
|
3849
|
+
rm -f "$HOST_ERR"
|
|
3850
|
+
jq -r --arg b "$ref" '.[] | select(.source.branch.name==$b) | (.source.commit.hash // empty)' <<<"$out" || exit 3
|
|
3851
|
+
else
|
|
3852
|
+
err="$(cat "$HOST_ERR" 2>/dev/null)"; rm -f "$HOST_ERR"
|
|
3853
|
+
if [ -n "$err" ] && is_lookup_miss "$err"; then
|
|
3854
|
+
:
|
|
3855
|
+
else
|
|
3856
|
+
echo "plot-host: ${err:-bb pr list failed}" >&2
|
|
3857
|
+
exit 3
|
|
3858
|
+
fi
|
|
3859
|
+
fi
|
|
3860
|
+
fi
|
|
3861
|
+
;;
|
|
3862
|
+
|
|
3726
3863
|
pr-create)
|
|
3727
3864
|
title=""; body=""; base=""; head=""; draft=0
|
|
3728
3865
|
while [ $# -gt 0 ]; do
|
|
@@ -3753,11 +3890,12 @@ case "$op" in
|
|
|
3753
3890
|
|
|
3754
3891
|
pr-merge)
|
|
3755
3892
|
num="${1:?pr-merge needs a PR number}"; shift
|
|
3756
|
-
squash=0; delbranch=0
|
|
3893
|
+
squash=0; delbranch=0; pin=""
|
|
3757
3894
|
while [ $# -gt 0 ]; do
|
|
3758
3895
|
case "$1" in
|
|
3759
3896
|
--squash) squash=1; shift ;;
|
|
3760
3897
|
--delete-branch) delbranch=1; shift ;;
|
|
3898
|
+
--match-head) pin="${2:?pr-merge --match-head needs a commit}"; shift 2 ;;
|
|
3761
3899
|
*) die "pr-merge: unknown arg $1" ;;
|
|
3762
3900
|
esac
|
|
3763
3901
|
done
|
|
@@ -3765,7 +3903,9 @@ case "$op" in
|
|
|
3765
3903
|
args=(pr merge "$num")
|
|
3766
3904
|
[ "$squash" = 1 ] && args+=(--squash) || args+=(--merge)
|
|
3767
3905
|
[ "$delbranch" = 1 ] && args+=(--delete-branch)
|
|
3906
|
+
[ -n "$pin" ] && args+=(--match-head-commit "$pin")
|
|
3768
3907
|
gh "${args[@]}"
|
|
3908
|
+
elif [ -n "$pin" ]; then echo "plot-host: pr-merge --match-head: bitbucket cannot pin a merge to a commit; nothing was merged" >&2; exit 4
|
|
3769
3909
|
else
|
|
3770
3910
|
args=(pr merge "$num")
|
|
3771
3911
|
[ "$squash" = 1 ] && args+=(--squash)
|
|
@@ -4035,6 +4175,11 @@ case "$op" in
|
|
|
4035
4175
|
# GitHub's statusCheckRollup. Done-when 3 verifies this is orthogonal:
|
|
4036
4176
|
# a GitHub repo without Jenkins still reads its own rollup exactly as
|
|
4037
4177
|
# before.
|
|
4178
|
+
# COMMIT FIELDS PER ARM. `headSha` is `headRefOid` on all three GitHub
|
|
4179
|
+
# arms. `checksSha` is emitted ONLY by the rollup arm: `statusCheckRollup`
|
|
4180
|
+
# belongs to the head commit, so it equals `headSha`. The Jenkins colours
|
|
4181
|
+
# are per branch and carry no commit, and the plain arm reads no checks,
|
|
4182
|
+
# so neither emits `checksSha`. `mergedAt` is the host's, `""` on an open PR.
|
|
4038
4183
|
if [ "$ci" = "jenkins" ]; then
|
|
4039
4184
|
# GitHub PR list, but `checks` comes from Jenkins, joined on branch
|
|
4040
4185
|
# name. `statusCheckRollup` is NOT even requested — the GitHub rollup
|
|
@@ -4044,7 +4189,7 @@ case "$op" in
|
|
|
4044
4189
|
# $jentry == null → the branch has no Jenkins job; `none`.
|
|
4045
4190
|
# otherwise → the joined colour's `checks`, job named on fail.
|
|
4046
4191
|
_gh_raw="$(pr_list_call gh ${repo_args[@]+"${repo_args[@]}"} pr list --state "$state" ${limit_args[@]+"${limit_args[@]}"} ${search_args[@]+"${search_args[@]}"} \
|
|
4047
|
-
--json number,title,state,headRefName,isDraft,mergeable,mergeStateStatus,reviewDecision,url,updatedAt,author)" || exit $?
|
|
4192
|
+
--json number,title,state,headRefName,isDraft,mergeable,mergeStateStatus,reviewDecision,url,updatedAt,author,headRefOid,mergedAt)" || exit $?
|
|
4048
4193
|
pr_list_report_truncation github "$limit" "$state" \
|
|
4049
4194
|
"$(jq 'length' <<<"$_gh_raw" 2>/dev/null || echo 0)"
|
|
4050
4195
|
printf '%s' "$_gh_raw" \
|
|
@@ -4064,7 +4209,7 @@ case "$op" in
|
|
|
4064
4209
|
else "unknown" end),
|
|
4065
4210
|
review:(.reviewDecision // ""),
|
|
4066
4211
|
url:.url,
|
|
4067
|
-
updatedAt:(.updatedAt // ""),
|
|
4212
|
+
updatedAt:(.updatedAt // ""),headSha:(.headRefOid // ""),mergedAt:(.mergedAt // ""),
|
|
4068
4213
|
author:(.author.login // ""),
|
|
4069
4214
|
failing_checks:(
|
|
4070
4215
|
if $jentry != null and $jentry.checks == "failing"
|
|
@@ -4075,35 +4220,24 @@ case "$op" in
|
|
|
4075
4220
|
else
|
|
4076
4221
|
# GitHub without Jenkins (or Jenkins not configured): use GitHub rollup
|
|
4077
4222
|
_gh_raw="$(pr_list_call gh ${repo_args[@]+"${repo_args[@]}"} pr list --state "$state" ${limit_args[@]+"${limit_args[@]}"} ${search_args[@]+"${search_args[@]}"} \
|
|
4078
|
-
--json number,title,state,headRefName,isDraft,statusCheckRollup,mergeable,mergeStateStatus,reviewDecision,url,updatedAt,author)" || exit $?
|
|
4223
|
+
--json number,title,state,headRefName,isDraft,statusCheckRollup,mergeable,mergeStateStatus,reviewDecision,url,updatedAt,author,headRefOid,mergedAt)" || exit $?
|
|
4079
4224
|
pr_list_report_truncation github "$limit" "$state" \
|
|
4080
4225
|
"$(jq 'length' <<<"$_gh_raw" 2>/dev/null || echo 0)"
|
|
4081
4226
|
printf '%s' "$_gh_raw" \
|
|
4082
|
-
| jq -c '.[] | {
|
|
4227
|
+
| jq -c "$CHECKS_OF"'.[] | {
|
|
4083
4228
|
number:.number, title:.title, state:.state, head:.headRefName,
|
|
4084
4229
|
draft:.isDraft,
|
|
4085
|
-
checks:
|
|
4086
|
-
if (.statusCheckRollup|length) == 0 then "none"
|
|
4087
|
-
elif any(.statusCheckRollup[]; (if (.conclusion // "") != "" then .conclusion else (.status // .state) end) as $c
|
|
4088
|
-
| $c=="FAILURE" or $c=="ERROR" or $c=="CANCELLED"
|
|
4089
|
-
or $c=="TIMED_OUT" or $c=="ACTION_REQUIRED") then "failing"
|
|
4090
|
-
elif any(.statusCheckRollup[]; (if (.conclusion // "") != "" then .conclusion else (.status // .state) end) as $c
|
|
4091
|
-
| $c=="PENDING" or $c=="IN_PROGRESS" or $c=="QUEUED"
|
|
4092
|
-
or $c=="WAITING" or $c==null) then "pending"
|
|
4093
|
-
else "green" end),
|
|
4230
|
+
checks:checks_of,
|
|
4094
4231
|
mergeable:(
|
|
4095
4232
|
if .mergeable=="CONFLICTING" or .mergeStateStatus=="DIRTY" then "conflicting"
|
|
4096
4233
|
elif .mergeable=="MERGEABLE" then "mergeable"
|
|
4097
4234
|
else "unknown" end),
|
|
4098
4235
|
review:(.reviewDecision // ""),
|
|
4099
4236
|
url:.url,
|
|
4100
|
-
updatedAt:(.updatedAt // ""),
|
|
4237
|
+
updatedAt:(.updatedAt // ""),headSha:(.headRefOid // ""),checksSha:(.headRefOid // ""),mergedAt:(.mergedAt // ""),
|
|
4101
4238
|
author:(.author.login // ""),
|
|
4102
4239
|
failing_checks:[
|
|
4103
|
-
.statusCheckRollup[]? | select(
|
|
4104
|
-
| $c=="FAILURE" or $c=="ERROR" or $c=="CANCELLED"
|
|
4105
|
-
or $c=="TIMED_OUT" or $c=="ACTION_REQUIRED")
|
|
4106
|
-
| (.name // .context // "")] | map(select(. != ""))
|
|
4240
|
+
.statusCheckRollup[]? | select(ck == "bad") | (.name // .context // "")] | map(select(. != ""))
|
|
4107
4241
|
}'
|
|
4108
4242
|
fi
|
|
4109
4243
|
else
|
|
@@ -4121,13 +4255,17 @@ case "$op" in
|
|
|
4121
4255
|
# the store unable to narrow and the daily full read would never fall
|
|
4122
4256
|
# due against anything but a cold window.
|
|
4123
4257
|
_gh_raw="$(pr_list_call gh ${repo_args[@]+"${repo_args[@]}"} pr list --state "$state" ${limit_args[@]+"${limit_args[@]}"} ${search_args[@]+"${search_args[@]}"} \
|
|
4124
|
-
--json number,title,state,headRefName,isDraft,url,updatedAt,author)" || exit $?
|
|
4258
|
+
--json number,title,state,headRefName,isDraft,url,updatedAt,author,headRefOid,mergedAt)" || exit $?
|
|
4125
4259
|
pr_list_report_truncation github "$limit" "$state" \
|
|
4126
4260
|
"$(jq 'length' <<<"$_gh_raw" 2>/dev/null || echo 0)"
|
|
4127
4261
|
printf '%s' "$_gh_raw" \
|
|
4128
|
-
| jq -c '.[] | {number:.number,title:.title,state:.state,head:.headRefName,draft:.isDraft,url:.url,updatedAt:(.updatedAt // ""),author:(.author.login // "")}'
|
|
4262
|
+
| jq -c '.[] | {number:.number,title:.title,state:.state,head:.headRefName,draft:.isDraft,url:.url,updatedAt:(.updatedAt // ""),headSha:(.headRefOid // ""),mergedAt:(.mergedAt // ""),author:(.author.login // "")}'
|
|
4129
4263
|
fi
|
|
4130
4264
|
else
|
|
4265
|
+
# `headSha` IS `.source.commit.hash`, which the pullrequests endpoint
|
|
4266
|
+
# carries. The endpoint has no `merged_on`, so `mergedAt` is `.updated_on`
|
|
4267
|
+
# of a MERGED PR only; `checksSha` is absent, as `bb` reads no checks.
|
|
4268
|
+
#
|
|
4131
4269
|
# `author` IS THE `nickname`, the one handle field a Bitbucket user
|
|
4132
4270
|
# object carries. Measured 2026-09-25 against bb 1.9.0: `author` holds
|
|
4133
4271
|
# `display_name`, `nickname`, `account_id` and `uuid` and no username,
|
|
@@ -4220,7 +4358,7 @@ case "$op" in
|
|
|
4220
4358
|
mergeable:"unknown",
|
|
4221
4359
|
review:"",
|
|
4222
4360
|
url:(.links.html.href // ""),
|
|
4223
|
-
updatedAt:(.updated_on // ""),
|
|
4361
|
+
updatedAt:(.updated_on // ""),headSha:(.source.commit.hash // ""),mergedAt:(if .state=="MERGED" then (.updated_on // "") else "" end),
|
|
4224
4362
|
author:(.author.nickname // ""),
|
|
4225
4363
|
failing_checks:(
|
|
4226
4364
|
if $jentry != null and $jentry.checks == "failing"
|
|
@@ -4232,7 +4370,7 @@ case "$op" in
|
|
|
4232
4370
|
# Bitbucket without Jenkins: checks remain unknown
|
|
4233
4371
|
PR_LIST_JQ_ARGS=()
|
|
4234
4372
|
pr_list_states bitbucket "$limit" "$bb_states" \
|
|
4235
|
-
'.[] | {number:.id,title:.title,state:(if .state=="DECLINED" then "CLOSED" else .state end),head:.source.branch.name,draft:(.draft // false),checks:"unknown",mergeable:"unknown",review:"",url:(.links.html.href // ""),updatedAt:(.updated_on // ""),author:(.author.nickname // ""),failing_checks:[]}' \
|
|
4373
|
+
'.[] | {number:.id,title:.title,state:(if .state=="DECLINED" then "CLOSED" else .state end),head:.source.branch.name,draft:(.draft // false),checks:"unknown",mergeable:"unknown",review:"",url:(.links.html.href // ""),updatedAt:(.updated_on // ""),headSha:(.source.commit.hash // ""),mergedAt:(if .state=="MERGED" then (.updated_on // "") else "" end),author:(.author.nickname // ""),failing_checks:[]}' \
|
|
4236
4374
|
"${bb_cmd[@]}" || exit $?
|
|
4237
4375
|
fi
|
|
4238
4376
|
else
|
|
@@ -4335,8 +4473,16 @@ case "$op" in
|
|
|
4335
4473
|
esac
|
|
4336
4474
|
;;
|
|
4337
4475
|
|
|
4338
|
-
run-for-sha)
|
|
4339
|
-
#
|
|
4476
|
+
run-for-sha|runs-for-sha)
|
|
4477
|
+
# `runs-for-sha` is this op's plural: EVERY run for the sha as a JSON array
|
|
4478
|
+
# (`[]` is an answer, exit 4 is *cannot be asked*), from ONE listing call and
|
|
4479
|
+
# no per-run `gh run view`. The default branch needs it because `main` runs
|
|
4480
|
+
# several workflows per commit and the first match alone would let a green
|
|
4481
|
+
# first run hide a red second one. Facts only: `status` and `conclusion` as
|
|
4482
|
+
# the host gives them, Jenkins' words included.
|
|
4483
|
+
#
|
|
4484
|
+
# The singular, below, is the BuildMonitor's only host question.
|
|
4485
|
+
#
|
|
4340
4486
|
#
|
|
4341
4487
|
# WHY THIS IS NOT `runs`. `runs` is branch-scoped and reports no sha at all,
|
|
4342
4488
|
# so a caller cannot tell which commit an answer is about. `gh run list
|
|
@@ -4366,8 +4512,8 @@ case "$op" in
|
|
|
4366
4512
|
# A Bitbucket remote exits 4 (`bb` has no run listing), as does a failing
|
|
4367
4513
|
# `gh` or Jenkins that cannot be asked: exit 4 reads as unavailable, never
|
|
4368
4514
|
# as "this sha has no build".
|
|
4369
|
-
branch="${1
|
|
4370
|
-
sha="${1
|
|
4515
|
+
branch="${1:?$op needs a branch}"; shift
|
|
4516
|
+
sha="${1:?$op needs a sha}"; shift
|
|
4371
4517
|
# Enough runs to find the sha among its neighbours. A branch accumulates
|
|
4372
4518
|
# runs per push and per workflow, so the sha being asked about can sit
|
|
4373
4519
|
# several entries down even when it is the current head.
|
|
@@ -4375,7 +4521,7 @@ case "$op" in
|
|
|
4375
4521
|
while [ $# -gt 0 ]; do
|
|
4376
4522
|
case "$1" in
|
|
4377
4523
|
--limit) limit="${2:?}"; shift 2 ;;
|
|
4378
|
-
*) die "
|
|
4524
|
+
*) die "$op: unknown arg $1" ;;
|
|
4379
4525
|
esac
|
|
4380
4526
|
done
|
|
4381
4527
|
# DISPATCHED ON THE CI SYSTEM, for the reason `runs` above states: the git
|
|
@@ -4396,80 +4542,11 @@ case "$op" in
|
|
|
4396
4542
|
#
|
|
4397
4543
|
# THIS ARM EXITED 4 UNTIL 2026-09-11, and the refusal was honest for
|
|
4398
4544
|
# the transport it had. What changed is the transport, not the rule.
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
[ "$
|
|
4404
|
-
[ -n "${PLOT_JENKINS_JOB:-}" ] && _jen_job="$PLOT_JENKINS_JOB"
|
|
4405
|
-
if [ -z "$_jen_job" ]; then
|
|
4406
|
-
# A bare-host instance names no job, and a sha lives in a job's
|
|
4407
|
-
# builds. `runs` degrades to an empty map here; this op has no row to
|
|
4408
|
-
# carry that, so the only way to say *cannot be asked* is exit 4.
|
|
4409
|
-
echo "plot-host: run-for-sha — the Jenkins instance names no job path" >&2
|
|
4410
|
-
echo " A sha is a fact about a job's builds, so the instance must be" >&2
|
|
4411
|
-
echo " <slug>/<job/path> rather than a bare host." >&2
|
|
4412
|
-
exit 4
|
|
4413
|
-
fi
|
|
4414
|
-
_jen_cred="$(jenkins_rest_credential "$_jen_host")" || {
|
|
4415
|
-
# NO CREDENTIAL IS *CANNOT BE ASKED*, never *no run*. The keychain is
|
|
4416
|
-
# macOS-only and a Linux agent legitimately has none; saying nothing
|
|
4417
|
-
# at exit 0 would read as a branch that never built.
|
|
4418
|
-
echo "plot-host: run-for-sha — no Jenkins API credential for '$_jen_host'" >&2
|
|
4419
|
-
echo " Jenkins' REST API takes basic auth with an API token, which" >&2
|
|
4420
|
-
echo " \`jen auth login\` stores in the login keychain. The Keycloak" >&2
|
|
4421
|
-
echo " bearer from \`jen auth token\` is NOT it — Jenkins answers that" >&2
|
|
4422
|
-
echo " with a login redirect." >&2
|
|
4423
|
-
exit 4
|
|
4424
|
-
}
|
|
4425
|
-
# A BRANCH IS A JOB SEGMENT ON A MULTIBRANCH JOB AND NOT ON A PLAIN
|
|
4426
|
-
# ONE, and no reading of the configured path says which this is. So the
|
|
4427
|
-
# multibranch URL is tried first and the plain one is the fallback:
|
|
4428
|
-
# `job/quaweb/job/continuous-build/job/content%2Fctas` against
|
|
4429
|
-
# `job/quaweb/job/release`. Measured 2026-09-11 — asking the plain job
|
|
4430
|
-
# for a branch segment answers 404, which is why guessing one shape
|
|
4431
|
-
# cost a run.
|
|
4432
|
-
#
|
|
4433
|
-
# THE PLAIN JOB REPORTS ITS OWN BUILDS whatever branch was asked about,
|
|
4434
|
-
# and that is honest rather than wrong: a pipeline job builds one
|
|
4435
|
-
# thing, and the `sha` in the answer says which commit it built.
|
|
4436
|
-
_jen_tree="tree=builds%5Bnumber,result,building,timestamp,url,actions%5BlastBuiltRevision%5BSHA1%5D%5D%5D%7B0,$limit%7D"
|
|
4437
|
-
_jen_body=""
|
|
4438
|
-
for _jen_path in \
|
|
4439
|
-
"$(jenkins_job_url_path "$_jen_job" "$branch")" \
|
|
4440
|
-
"$(jenkins_job_url_path "$_jen_job" "")"; do
|
|
4441
|
-
host_slot_take jenkins ''
|
|
4442
|
-
_jen_try=$(curl -sg --max-time 30 -u "$_jen_cred" \
|
|
4443
|
-
"https://$_jen_host$_jen_path/api/json?$_jen_tree" 2>/dev/null) || true
|
|
4444
|
-
host_slot_give
|
|
4445
|
-
budget_record_call jenkins ''
|
|
4446
|
-
if printf '%s' "$_jen_try" | jq -e 'has("builds")' >/dev/null 2>&1; then
|
|
4447
|
-
_jen_body="$_jen_try"; break
|
|
4448
|
-
fi
|
|
4449
|
-
done
|
|
4450
|
-
_jen_cred=""
|
|
4451
|
-
if [ -z "$_jen_body" ] || ! printf '%s' "$_jen_body" | jq -e 'has("builds")' >/dev/null 2>&1; then
|
|
4452
|
-
# AN UNREACHABLE INSTANCE IS NOT AN EMPTY HISTORY. A refused or
|
|
4453
|
-
# redirected request answers HTML, which fails the `builds` test.
|
|
4454
|
-
echo "plot-host: run-for-sha — Jenkins did not answer for '$_jen_host'" >&2
|
|
4455
|
-
exit 4
|
|
4456
|
-
fi
|
|
4457
|
-
# THE SAME MATCH RULE AS THE GITHUB ARM: only the asked-for sha, never
|
|
4458
|
-
# another build's. A build for any other commit is not evidence about
|
|
4459
|
-
# this one, so no match means no output.
|
|
4460
|
-
#
|
|
4461
|
-
# `result` is null while a build runs, which is Jenkins' own word for
|
|
4462
|
-
# *in flight* — mapped to the `status`/`conclusion` split the contract
|
|
4463
|
-
# already uses, so the shape does not fork per connector.
|
|
4464
|
-
printf '%s' "$_jen_body" | jq -c --arg sha "$sha" '
|
|
4465
|
-
[ .builds[]
|
|
4466
|
-
| { sha: ([ .actions[]? | select(.lastBuiltRevision) | .lastBuiltRevision.SHA1 ] | first // ""),
|
|
4467
|
-
status: (if .building then "in_progress" else "completed" end),
|
|
4468
|
-
conclusion: (if .building then null else (.result // null) end),
|
|
4469
|
-
url: (.url // ""),
|
|
4470
|
-
startedAt: (if .timestamp then (.timestamp / 1000 | todate) else "" end) } ]
|
|
4471
|
-
| (map(select(.sha == $sha)) | .[0])
|
|
4472
|
-
| select(. != null)' 2>/dev/null || true
|
|
4545
|
+
# The fetch, credential and match rule live in `jenkins_sha_runs`, which
|
|
4546
|
+
# `runs-for-sha` shares. `|| exit $?` keeps exit 3 (no instance) apart
|
|
4547
|
+
# from exit 4 (cannot be asked).
|
|
4548
|
+
_jen_all=$(jenkins_sha_runs "$op" "$branch" "$limit" "$sha") || exit $?
|
|
4549
|
+
if [ "$op" = runs-for-sha ]; then printf '%s' "$_jen_all"; else printf '%s' "$_jen_all" | jq -c '.[0] // empty' 2>/dev/null || true; fi
|
|
4473
4550
|
# THIS ARM ANSWERS AND THE OP IS OVER. Everything below the `esac` is
|
|
4474
4551
|
# the GitHub path — the old jenkins arm reached it only because it
|
|
4475
4552
|
# ended in `exit 4`. Measured 2026-09-11: without this the answer was
|
|
@@ -4478,13 +4555,13 @@ case "$op" in
|
|
|
4478
4555
|
exit 0
|
|
4479
4556
|
;;
|
|
4480
4557
|
github-actions) : ;;
|
|
4481
|
-
*) ci_unaskable
|
|
4558
|
+
*) ci_unaskable "$op" "$_ci" ;;
|
|
4482
4559
|
esac
|
|
4483
4560
|
if [ "$be" != "github" ]; then
|
|
4484
4561
|
# SAME SECOND CONDITION AS `runs`: `gh run list` reads the repository its
|
|
4485
4562
|
# remote names, so `CI: github-actions` on a non-GitHub remote names runs
|
|
4486
4563
|
# that cannot be reached from here.
|
|
4487
|
-
echo "plot-host:
|
|
4564
|
+
echo "plot-host: $op — CI is github-actions but the git host is '$be'" >&2
|
|
4488
4565
|
echo " \`gh run list\` reads the runs of the repository its remote names," >&2
|
|
4489
4566
|
echo " so there is no GitHub repository here to ask about." >&2
|
|
4490
4567
|
exit 4
|
|
@@ -4509,8 +4586,15 @@ case "$op" in
|
|
|
4509
4586
|
# a network failure exits 4 here, the way the Jenkins arm does, so the
|
|
4510
4587
|
# monitor reads *could not ask* and not *no run yet*.
|
|
4511
4588
|
_gh_runs=$(gh run list --branch "$branch" --limit "$limit" \
|
|
4512
|
-
--json headSha,conclusion,status,startedAt,url,databaseId 2>/dev/null) \
|
|
4513
|
-
|| { echo "plot-host:
|
|
4589
|
+
--json headSha,conclusion,status,startedAt,url,databaseId,workflowName 2>/dev/null) \
|
|
4590
|
+
|| { echo "plot-host: $op — gh run list failed for '$branch'" >&2; exit 4; }
|
|
4591
|
+
if [ "$op" = runs-for-sha ]; then
|
|
4592
|
+
printf '%s' "$_gh_runs" | jq -c --arg sha "$sha" '[.[] | select(.headSha == $sha)
|
|
4593
|
+
| {sha:.headSha, workflow:(.workflowName // ""), status:.status,
|
|
4594
|
+
conclusion:(if (.conclusion // "") == "" then null else .conclusion end),
|
|
4595
|
+
url:.url, startedAt:.startedAt}]' || exit 4
|
|
4596
|
+
exit 0
|
|
4597
|
+
fi
|
|
4514
4598
|
_gh_match=$(printf '%s' "$_gh_runs" | jq -c --arg sha "$sha" \
|
|
4515
4599
|
'(map(select(.headSha == $sha)) | .[0]) | select(. != null)
|
|
4516
4600
|
| {sha:.headSha, status:.status,
|