@plot-pm/board 0.24.0 → 0.25.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 +253 -201
- package/package.json +1 -1
- package/plot-dispatch.sh +1 -1
- package/plot-host.sh +85 -99
package/package.json
CHANGED
package/plot-dispatch.sh
CHANGED
|
@@ -1013,7 +1013,7 @@ ask_start_command() { # $1 = free | assigned
|
|
|
1013
1013
|
start_cmd_configured=$("$script_dir/plot-config.sh" get "Worker command" "")
|
|
1014
1014
|
start_cmd_bundle="$script_dir/board/plot-start-command.mjs"
|
|
1015
1015
|
answer=$(printf '%s' "$start_cmd_configured" | node "$start_cmd_bundle" "$1" \
|
|
1016
|
-
plot-worker-loop.sh "PLOT_UNATTENDED=1 plot-worker-loop.sh" 2>/dev/null)
|
|
1016
|
+
plot-worker-loop.sh "PLOT_UNATTENDED=1 plot-worker-loop.sh" "$repo_root" "$("$script_dir/plot-config.sh" get "Agent runner" "")" 2>/dev/null)
|
|
1017
1017
|
rc=$?
|
|
1018
1018
|
case "$rc:$answer" in
|
|
1019
1019
|
0:run$'\t'*) start_cmd_verb=run; start_cmd_run=${answer#run$'\t'} ;;
|
package/plot-host.sh
CHANGED
|
@@ -111,12 +111,21 @@
|
|
|
111
111
|
# (exit 0) where none merged. The same query
|
|
112
112
|
# `pr-merge-commit` runs. EXIT 3 is the question
|
|
113
113
|
# failing.
|
|
114
|
-
# pr-review <number> one JSON line `{"sha","state","description","time","bypass"}`:
|
|
114
|
+
# pr-review <number> one JSON line `{"sha","state","description","time","bypass","statuses"}`:
|
|
115
115
|
# the PR's head sha, the newest `plot/review`
|
|
116
|
-
# status on it
|
|
117
|
-
#
|
|
118
|
-
#
|
|
119
|
-
#
|
|
116
|
+
# status on it from ANY writer
|
|
117
|
+
# (`success|failure|pending|error`, or
|
|
118
|
+
# `absent`), that status's description and
|
|
119
|
+
# time (both `""` where state is `absent`),
|
|
120
|
+
# whether a comment starts `review-bypass:`, and
|
|
121
|
+
# `statuses`: every `plot/review` status on the
|
|
122
|
+
# head, newest first, as `{"state",
|
|
123
|
+
# "description","time","writer"}` where
|
|
124
|
+
# `writer` is `creator.login` (`""` where the
|
|
125
|
+
# host names none). GitHub reads every page of
|
|
126
|
+
# the head's statuses. The op reports and
|
|
127
|
+
# decides nothing: `checkedReview` judges
|
|
128
|
+
# `statuses` against the Review app's bot login.
|
|
120
129
|
# Bitbucket reads the same state words from the
|
|
121
130
|
# `plot/review` commit status (SUCCESSFUL,
|
|
122
131
|
# FAILED, INPROGRESS, STOPPED), its
|
|
@@ -635,7 +644,7 @@
|
|
|
635
644
|
# - no auto-merge / merge queues — pr-merge merges immediately or fails
|
|
636
645
|
# - "closed" state is Bitbucket's DECLINED (normalized to CLOSED here)
|
|
637
646
|
# - pr-state by BRANCH resolves via pr-list filtering (one extra call)
|
|
638
|
-
# - draft flag support
|
|
647
|
+
# - draft flag support: `bb pr create --draft`, `bb pr edit <n> --ready`
|
|
639
648
|
# Small-model consumption: structured output, no interpretation, exit 0 with
|
|
640
649
|
# state NONE rather than nonzero on lookup misses.
|
|
641
650
|
|
|
@@ -1907,26 +1916,6 @@ jenkins_no_instance() {
|
|
|
1907
1916
|
# estimate for. This draws it one step earlier, for a connector that does not
|
|
1908
1917
|
# exist at all — and `resultOf` (`adapters/run-script.ts:211`) maps exit 4 onto
|
|
1909
1918
|
# `unaskable`, which is the word the build port already answers with.
|
|
1910
|
-
# The Jenkins REST credential: JENKINS_USER + JENKINS_API_TOKEN from the
|
|
1911
|
-
# environment, then `plot_env_file`, then the macOS keychain where `jen`
|
|
1912
|
-
# already stores it — the environment wins outright, same order and the same
|
|
1913
|
-
# both-or-neither rule as `jira_load_env_file`.
|
|
1914
|
-
#
|
|
1915
|
-
# NOT THE KEYCLOAK BEARER. `jen auth token` prints one and Jenkins answers it
|
|
1916
|
-
# with an HTML login redirect — measured 2026-09-10. Jenkins' own API takes
|
|
1917
|
-
# BASIC auth with a user and an API token.
|
|
1918
|
-
#
|
|
1919
|
-
# Prints `user:token` and nothing else, or nothing at all — never the value
|
|
1920
|
-
# on a failure path. Empty means no source held a full pair; the caller turns
|
|
1921
|
-
# that into exit 4, *cannot be asked*.
|
|
1922
|
-
jenkins_rest_credential() { # $1 = the bare host
|
|
1923
|
-
local u="${JENKINS_USER:-}" t="${JENKINS_API_TOKEN:-}" src="the environment" found env_file
|
|
1924
|
-
[ -n "$u" ] || [ -n "$t" ] || { found="$(plot_env_file JENKINS_USER JENKINS_API_TOKEN)"; [ -n "$found" ] && env_file="${found%|*}" && src="${found#*|}.env" && u="$(read_env_var JENKINS_USER "$env_file")" && t="$(read_env_var JENKINS_API_TOKEN "$env_file")"; }
|
|
1925
|
-
[ -n "$u" ] && [ -n "$t" ] && { echo "plot-host: JENKINS_USER and JENKINS_API_TOKEN read from $src" >&2; printf '%s:%s' "$u" "$t"; return 0; }
|
|
1926
|
-
command -v security >/dev/null 2>&1 || return 1; u=$(security find-generic-password -s jen -a "jenkins-user:$1" -w 2>/dev/null) || return 1
|
|
1927
|
-
t=$(security find-generic-password -s jen -a "jenkins-token:$1" -w 2>/dev/null) || return 1
|
|
1928
|
-
[ -n "$u" ] && [ -n "$t" ] || return 1; printf '%s:%s' "$u" "$t"
|
|
1929
|
-
}
|
|
1930
1919
|
|
|
1931
1920
|
# A job path as Jenkins' REST API spells it: every segment under `job/`.
|
|
1932
1921
|
#
|
|
@@ -1943,20 +1932,6 @@ jenkins_job_url_path() { # $1 = job path, $2 = branch or ""
|
|
|
1943
1932
|
printf '%s' "$out"
|
|
1944
1933
|
}
|
|
1945
1934
|
|
|
1946
|
-
# The REST host for the Jenkins slug $1, read off `jen -I <slug> auth status`'s
|
|
1947
|
-
# `Instance:` line rather than reinvented here — `jen` already turns a slug
|
|
1948
|
-
# like `ewz` into `jenkins-ci-ewz.internal.quatico.dev` and keys its stored
|
|
1949
|
-
# credential by that resolved host, so a literal slug sent to `curl` or to
|
|
1950
|
-
# `jenkins_rest_credential` can only fail. Prints nothing and exits 1 when
|
|
1951
|
-
# `jen` is missing, unparseable, or the line is absent; exits 2 when the line
|
|
1952
|
-
# names no parenthesized host. The caller decides what an unresolved host
|
|
1953
|
-
# means, same contract as every other helper here.
|
|
1954
|
-
jenkins_resolve_host() {
|
|
1955
|
-
local line; line=$(jen -I "$1" auth status 2>&1 | grep -iE '^Instance:' | head -1)
|
|
1956
|
-
[ -n "$line" ] || return 1
|
|
1957
|
-
sed -nE 's/.*\(https?:\/\/([^)\/]+).*/\1/p' <<<"$line" | grep . || return 2
|
|
1958
|
-
}
|
|
1959
|
-
|
|
1960
1935
|
# Every Jenkins build of one job, as a JSON array (newest first), or exit 3
|
|
1961
1936
|
# (no instance) / exit 4 (cannot be asked). Shared by `run-for-sha`,
|
|
1962
1937
|
# `runs-for-sha` and `runs`, so the instance, the credential and the
|
|
@@ -1968,10 +1943,11 @@ jenkins_resolve_host() {
|
|
|
1968
1943
|
# Run it in `$(...)` and read the exit code with `|| exit $?`: it exits rather
|
|
1969
1944
|
# than returns, and a subshell's exit is the code the caller sees.
|
|
1970
1945
|
#
|
|
1971
|
-
#
|
|
1972
|
-
# `
|
|
1973
|
-
#
|
|
1974
|
-
#
|
|
1946
|
+
# Plot reaches Jenkins only through `jen`; `jen api` carries the sha through
|
|
1947
|
+
# `tree=` in one round trip. Measured 2026-09-10: a `jen build list --json`
|
|
1948
|
+
# entry carries no sha, so Jenkins' REST API answers it at
|
|
1949
|
+
# `actions[].lastBuiltRevision.SHA1`, and `jen api <path>` (jen 0.4.0) is the
|
|
1950
|
+
# raw passthrough that reaches it with the proxy's own auth headers.
|
|
1975
1951
|
#
|
|
1976
1952
|
# A BRANCH IS A JOB SEGMENT ON A MULTIBRANCH JOB AND NOT ON A PLAIN ONE, and no
|
|
1977
1953
|
# reading of the configured path says which this is. The multibranch URL is
|
|
@@ -1983,10 +1959,9 @@ jenkins_resolve_host() {
|
|
|
1983
1959
|
# path segment, as `jenkins_build_map` keys it). A multibranch container that
|
|
1984
1960
|
# answers `jobs` and no `builds` has not indexed the branch: an empty history.
|
|
1985
1961
|
#
|
|
1986
|
-
#
|
|
1987
|
-
#
|
|
1988
|
-
#
|
|
1989
|
-
# `builds` test.
|
|
1962
|
+
# A `jen` THAT CANNOT AUTHENTICATE IS *CANNOT BE ASKED*, never *no run*; an
|
|
1963
|
+
# unreachable instance is not an empty history. A refused or redirected
|
|
1964
|
+
# request answers HTML, which fails the `builds` test.
|
|
1990
1965
|
#
|
|
1991
1966
|
# A BRANCH THE MULTIBRANCH JOB NEVER INDEXED IS AN EMPTY HISTORY, NOT A
|
|
1992
1967
|
# REFUSAL. Measured live on ewz-kus-portal: `develop` builds in a separate job
|
|
@@ -2031,8 +2006,8 @@ jenkins_resolve_host() {
|
|
|
2031
2006
|
# the cut silently shrinks the answer — `runs --limit 3` over five builds where
|
|
2032
2007
|
# two are `NOT_BUILT` returning 1 row instead of 3. The over-fetch factor is
|
|
2033
2008
|
# fixed at 3x, uncapped: it costs response BYTES, never an extra round trip or
|
|
2034
|
-
# rate-budget slot (`
|
|
2035
|
-
#
|
|
2009
|
+
# rate-budget slot (the `jen()` wrapper records one ledger row per path
|
|
2010
|
+
# regardless of `limit`), and a single multibranch job's full history is
|
|
2036
2011
|
# small enough that 3x of any realistic `--limit` stays well under what one
|
|
2037
2012
|
# `tree=` query already returns today (measured 2026-09-10: 4855 bytes for
|
|
2038
2013
|
# five builds).
|
|
@@ -2041,35 +2016,24 @@ jenkins_resolve_host() {
|
|
|
2041
2016
|
# is tried first; if it answers real JSON with no `builds` key, Jenkins
|
|
2042
2017
|
# reached the job and simply has no such branch, and the refusal says so.
|
|
2043
2018
|
# Only the root-path retry's container check (above) can turn that into an
|
|
2044
|
-
# empty-history read instead. A host that never answers at all —
|
|
2045
|
-
#
|
|
2046
|
-
# since nothing there proves Jenkins was even reached.
|
|
2019
|
+
# empty-history read instead. A host that never answers at all — a failed
|
|
2020
|
+
# `jen api` request, HTML, empty body — gets the generic "did not answer"
|
|
2021
|
+
# refusal, since nothing there proves Jenkins was even reached.
|
|
2047
2022
|
jenkins_sha_runs() {
|
|
2048
|
-
local op="$1" branch="$2" limit="$3" sha="$4" instance slug
|
|
2023
|
+
local op="$1" branch="$2" limit="$3" sha="$4" instance slug job tree body try path plain="" default_job root_path branch_path branch_answered="" err_tmp err_line
|
|
2049
2024
|
instance="$(jenkins_instance)"; [ -n "$instance" ] || jenkins_no_instance
|
|
2050
2025
|
slug="${instance%%/*}"; job="${instance#*/}"; [ "$job" = "$instance" ] && job=""
|
|
2051
2026
|
default_job=$(bash "$here/plot-config.sh" get "Default branch job" "" 2>/dev/null || true); [ -n "$default_job" ] && [ "$branch" = "$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null | sed 's#^origin/##')" ] && job="$default_job"
|
|
2052
2027
|
[ -n "${PLOT_JENKINS_JOB:-}" ] && job="$PLOT_JENKINS_JOB"; [ -n "$job" ] || { 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; exit 4; }
|
|
2053
|
-
# A dotted slug IS a host already, `jen`'s own passthrough rule — only a
|
|
2054
|
-
# bare slug (`ewz`) needs resolving to the host its credential is keyed by.
|
|
2055
|
-
case "$slug" in *.*) host="$slug" ;; *) host="$(jenkins_resolve_host "$slug")" || {
|
|
2056
|
-
[ $? = 2 ] && printf '%s\n' "plot-host: $op — cannot resolve Jenkins instance '$slug' to a host" " \`jen -I $slug auth status\` answered an 'Instance:' line that names no (https://…) host; run it directly to see what it names." >&2 || printf '%s\n' "plot-host: $op — cannot resolve Jenkins instance '$slug' to a host" " \`jen -I $slug auth status\` did not answer an 'Instance:' line; run it directly to see why." >&2
|
|
2057
|
-
exit 4; } ;; esac
|
|
2058
|
-
cred="$(jenkins_rest_credential "$host")" || {
|
|
2059
|
-
echo "plot-host: $op — no Jenkins API credential for '$host'" >&2
|
|
2060
|
-
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
|
|
2061
|
-
exit 4
|
|
2062
|
-
}
|
|
2063
2028
|
tree="tree=builds%5Bnumber,result,building,timestamp,url,actions%5BlastBuiltRevision%5BSHA1,branch%5Bname%5D%5D%5D%5D%7B0,$((limit * 3))%7D"
|
|
2064
2029
|
body=""; root_path="$(jenkins_job_url_path "$job" "")"; branch_path="$(jenkins_job_url_path "$job" "$branch")"
|
|
2065
2030
|
for path in "$branch_path" "$root_path"; do
|
|
2066
|
-
|
|
2067
|
-
try=$(
|
|
2068
|
-
host_slot_give; budget_record_call jenkins ''
|
|
2031
|
+
plot_tmpfile err_tmp host-jenkins-sha-err || { echo "plot-host: $op — no temp file could be made under ${TMPDIR:-/tmp}" >&2; exit 3; }
|
|
2032
|
+
try=$(PLOT_JEN_BOUND_S="${PLOT_JENKINS_SHA_BOUND_S:-30}" jen -I "$slug" api "$path/api/json?$tree" 2>"$err_tmp") || true
|
|
2069
2033
|
if printf '%s' "$try" | jq -e 'has("builds")' >/dev/null 2>&1; then body="$try"; break; fi
|
|
2070
2034
|
# A branch path that came back as REAL JSON (jq could parse and evaluate
|
|
2071
2035
|
# it, just found no `builds` key) means Jenkins answered and indexed no
|
|
2072
|
-
# such branch — distinct from
|
|
2036
|
+
# such branch — distinct from `jen` failing outright or answering HTML,
|
|
2073
2037
|
# where jq's own exit code is 4 (empty input) or 5 (parse error) rather
|
|
2074
2038
|
# than the 1 a successfully-evaluated `false` reports.
|
|
2075
2039
|
[ "$path" = "$branch_path" ] && printf '%s' "$try" | jq -e . >/dev/null 2>&1 && branch_answered=1
|
|
@@ -2083,8 +2047,23 @@ jenkins_sha_runs() {
|
|
|
2083
2047
|
[ "$path" = "$root_path" ] && printf '%s' "$try" | jq -e '._class == "org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject"' >/dev/null 2>&1 && { body='{"builds":[]}'; break; }
|
|
2084
2048
|
plain=1
|
|
2085
2049
|
done
|
|
2086
|
-
|
|
2087
|
-
|
|
2050
|
+
if [ -z "$body" ]; then
|
|
2051
|
+
if [ -n "$branch_answered" ]; then
|
|
2052
|
+
echo "plot-host: $op — Jenkins has no branch '$branch' indexed for '$job'" >&2
|
|
2053
|
+
else
|
|
2054
|
+
err_line="$(grep -m1 '^error:' "$err_tmp" 2>/dev/null || true)"
|
|
2055
|
+
if grep -qi 'unknown command: api' "$err_tmp" 2>/dev/null; then
|
|
2056
|
+
echo "plot-host: $op — the sha read needs jen 0.4.0 or later with \`api\`" >&2
|
|
2057
|
+
elif grep -qiE 'command not found|no such file or directory' "$err_tmp" 2>/dev/null; then
|
|
2058
|
+
echo "plot-host: $op — \`jen\` is not installed; the sha read needs jen 0.4.0 or later with \`api\`" >&2
|
|
2059
|
+
else
|
|
2060
|
+
printf '%s\n' "plot-host: $op — Jenkins did not answer for Jenkins instance '$slug'" >&2
|
|
2061
|
+
[ -n "$err_line" ] && printf ' jen: %s\n' "$err_line" >&2
|
|
2062
|
+
printf ' Plot reaches Jenkins only through `jen`; run `jen auth login`.\n' >&2
|
|
2063
|
+
fi
|
|
2064
|
+
fi
|
|
2065
|
+
exit 4
|
|
2066
|
+
fi
|
|
2088
2067
|
printf '%s' "$body" | jq -c --arg sha "$sha" --arg job "$job" --arg branch "$branch" --arg plain "$plain" --argjson limit "$limit" 'def headsha($records): ($records | map(select(any(.branches[]; . == $branch))) | first.sha) // (if [$records[].branches[]] | length == 0 then $records | last.sha // "" else "" end);
|
|
2089
2068
|
[ .builds[]
|
|
2090
2069
|
| { records: [ .actions[]? | select(.lastBuiltRevision) | .lastBuiltRevision
|
|
@@ -2548,16 +2527,11 @@ gh_route() { # $1=op → graphql|rest
|
|
|
2548
2527
|
# `gh pr view 7` infers the repo from the git remote, but `gh api repos/.../pulls/7`
|
|
2549
2528
|
# has to be told. So the fallback needs one more fact than the path it replaces.
|
|
2550
2529
|
#
|
|
2551
|
-
# `--repo` may already carry it (the caller passed `-R owner/repo`)
|
|
2552
|
-
#
|
|
2553
|
-
#
|
|
2554
|
-
# TODO(decision): resolve the repo when `--repo` was not supplied.
|
|
2530
|
+
# `--repo` may already carry it (the caller passed `-R owner/repo`). Otherwise
|
|
2531
|
+
# `gh api` fills `{owner}/{repo}` from the git remote, with no request. A path
|
|
2532
|
+
# naming no real repository answers 404, which `is_lookup_miss` reads as NONE.
|
|
2555
2533
|
gh_rest_repo() {
|
|
2556
|
-
if [ ${#repo_args[@]} -gt 0 ]; then
|
|
2557
|
-
echo "${repo_args[1]}"
|
|
2558
|
-
return 0
|
|
2559
|
-
fi
|
|
2560
|
-
echo "TODO"
|
|
2534
|
+
if [ ${#repo_args[@]} -gt 0 ]; then echo "${repo_args[1]}"; else echo '{owner}/{repo}'; fi
|
|
2561
2535
|
}
|
|
2562
2536
|
|
|
2563
2537
|
rest_pr_to_state() {
|
|
@@ -3904,8 +3878,20 @@ bb() {
|
|
|
3904
3878
|
|
|
3905
3879
|
jen() {
|
|
3906
3880
|
host_slot_take jenkins ''
|
|
3907
|
-
|
|
3908
|
-
|
|
3881
|
+
local rc
|
|
3882
|
+
if [ -n "${PLOT_JEN_BOUND_S:-}" ]; then
|
|
3883
|
+
local pid watcher was_m
|
|
3884
|
+
case $- in *m*) was_m=yes ;; *) was_m=no ;; esac; set -m
|
|
3885
|
+
command jen "$@" & pid=$!
|
|
3886
|
+
( sleep "$PLOT_JEN_BOUND_S"; kill -TERM "-$pid" ) >/dev/null 2>&1 & watcher=$!
|
|
3887
|
+
wait "$pid"; rc=$?
|
|
3888
|
+
kill "$watcher" 2>/dev/null; wait "$watcher" 2>/dev/null
|
|
3889
|
+
[ "$was_m" = yes ] || set +m
|
|
3890
|
+
[ $rc = 143 ] && echo "jen api gave no answer within ${PLOT_JEN_BOUND_S} s" >&2
|
|
3891
|
+
else
|
|
3892
|
+
command jen "$@"
|
|
3893
|
+
rc=$?
|
|
3894
|
+
fi
|
|
3909
3895
|
host_slot_give
|
|
3910
3896
|
# Jenkins is the CI axis, a connector of its own — this repo is GitHub +
|
|
3911
3897
|
# Actions while `ekzweb` is Bitbucket + Jenkins, so a `jen` call spends
|
|
@@ -4086,7 +4072,7 @@ case "$op" in
|
|
|
4086
4072
|
# for anything unmerged, which is the honest answer rather than a guess.
|
|
4087
4073
|
elif out="$(gh ${repo_args[@]+"${repo_args[@]}"} pr view "$ref" --json number,state,isDraft,url,mergeCommit,headRefName,headRefOid,baseRefName,statusCheckRollup,mergeable,mergeStateStatus,mergedAt 2>"$HOST_ERR")"; then
|
|
4088
4074
|
rm -f "$HOST_ERR"
|
|
4089
|
-
jq -c "$CHECKS_OF$MERGEABLE_OF"'{number:.number,state:.state,draft:.isDraft,url:.url,mergeCommit:(.mergeCommit.oid // ""),head:(.headRefName // ""),headSha:(.headRefOid // ""),base:(.baseRefName // ""),checks:checks_of,checksSha:(.headRefOid // ""),mergeable:mergeable_of,mergedAt:(.mergedAt // "")}' <<<"$out"
|
|
4075
|
+
jq -c "$CHECKS_OF$MERGEABLE_OF"'{number:.number,state:.state,draft:.isDraft,url:.url,mergeCommit:(.mergeCommit.oid // ""),head:(.headRefName // ""),headSha:(.headRefOid // ""),base:(.baseRefName // ""),checks:checks_of,ciChecks:ci_checks_of,checksSha:(.headRefOid // ""),mergeable:mergeable_of,mergedAt:(.mergedAt // "")}' <<<"$out"
|
|
4090
4076
|
else
|
|
4091
4077
|
host_err
|
|
4092
4078
|
# REFUSED FOR RATE IS NOT ANSWERED. The budget gate above could not see
|
|
@@ -4391,8 +4377,12 @@ case "$op" in
|
|
|
4391
4377
|
&& printf '%s\n%s\n%s\n' "$sha" "$st" "$cm" | node "$here/board/plot-jenkins-pr-checks.mjs" review \
|
|
4392
4378
|
|| die3 "pr-review: the read failed"
|
|
4393
4379
|
exit 0; fi
|
|
4394
|
-
|
|
4395
|
-
|
|
4380
|
+
# EVERY `plot/review` STATUS IS REPORTED WITH ITS WRITER, and nothing is
|
|
4381
|
+
# decided here: `checkedReview` judges the list against the Review app's bot
|
|
4382
|
+
# login. The pages and the PR travel through stdin, never `--argjson` (the
|
|
4383
|
+
# 128 KB argv cap on Linux).
|
|
4384
|
+
out="$(gh pr view "${1:?pr-review needs a PR number}" --json headRefOid,comments)" && st="$(gh api --paginate "repos/{owner}/{repo}/commits/$(jq -r .headRefOid <<<"$out")/statuses?per_page=100")" \
|
|
4385
|
+
&& printf '%s\n%s\n' "$out" "$st" | jq -cs '.[0] as $pr | [.[1:][][] | select(.context == "plot/review")] as $s | $s[0] as $m | {sha: $pr.headRefOid, state: ($m.state // "absent"), description: ($m.description // ""), time: ($m.updated_at // ""), bypass: any($pr.comments[]?; .body | startswith("review-bypass:")), statuses: [$s[] | {state, description: (.description // ""), time: (.updated_at // ""), writer: (.creator.login // "")}]}' \
|
|
4396
4386
|
|| die3 "pr-review: the read failed" ;;
|
|
4397
4387
|
|
|
4398
4388
|
pr-create)
|
|
@@ -4457,14 +4447,13 @@ case "$op" in
|
|
|
4457
4447
|
# the second; reaching for `gh` there would put a second host caller in the
|
|
4458
4448
|
# estate.
|
|
4459
4449
|
#
|
|
4460
|
-
# Bitbucket
|
|
4461
|
-
#
|
|
4462
|
-
#
|
|
4463
|
-
#
|
|
4464
|
-
# PR is now ready or closed*.
|
|
4450
|
+
# Bitbucket runs `bb pr edit <n> --ready` (see the caveat list at the top of
|
|
4451
|
+
# this file), so a failure here surfaces as the CLI's own message rather
|
|
4452
|
+
# than being swallowed: the caller must be able to tell *the host refused*
|
|
4453
|
+
# from *the PR is now ready or closed*.
|
|
4465
4454
|
num="${1:?$op needs a PR number}"
|
|
4466
4455
|
if [ "$op" = "pr-ready" ] && [ "$cli" = "bb" ]; then
|
|
4467
|
-
bb pr
|
|
4456
|
+
bb pr edit "$num" --ready
|
|
4468
4457
|
else
|
|
4469
4458
|
"$cli" pr "${op#pr-}" "$num"
|
|
4470
4459
|
fi
|
|
@@ -4976,7 +4965,7 @@ case "$op" in
|
|
|
4976
4965
|
fi
|
|
4977
4966
|
else
|
|
4978
4967
|
pr_list_states bitbucket "$limit" "$bb_states" \
|
|
4979
|
-
'.[] | {number:.id,title:.title,state:(if .state=="DECLINED" then "CLOSED" else .state end),head:.source.branch.name,author:(.author.nickname // "")}' \
|
|
4968
|
+
'.[] | {number:.id,title:.title,state:(if .state=="DECLINED" then "CLOSED" else .state end),head:.source.branch.name,draft:(.draft // false),url:(.links.html.href // ""),updatedAt:(.updated_on // ""),headSha:(.source.commit.hash // ""),mergedAt:(if .state=="MERGED" then (.updated_on // "") else "" end),author:(.author.nickname // ""),base:(.destination.branch.name // "")}' \
|
|
4980
4969
|
"${bb_cmd[@]}" || exit $?
|
|
4981
4970
|
fi
|
|
4982
4971
|
fi
|
|
@@ -5107,20 +5096,17 @@ case "$op" in
|
|
|
5107
5096
|
_ci="$(ci_scheme)"
|
|
5108
5097
|
case "$_ci" in
|
|
5109
5098
|
jenkins)
|
|
5110
|
-
#
|
|
5099
|
+
# `jen api` IS THE RAW PASSTHROUGH AND THE ONLY TRANSPORT. Measured
|
|
5111
5100
|
# 2026-09-10 against a live instance: a build entry from `jen build
|
|
5112
5101
|
# list --json` carries `id`, `status`, timings and stages, and a search
|
|
5113
5102
|
# of the whole payload for `sha|commit|revision|scm` matches nothing.
|
|
5114
|
-
#
|
|
5115
|
-
#
|
|
5116
|
-
#
|
|
5117
|
-
# `actions[].lastBuiltRevision.SHA1`, paired with the branch. One
|
|
5103
|
+
# Jenkins' own REST API answers it at
|
|
5104
|
+
# `actions[].lastBuiltRevision.SHA1`, paired with the branch, and
|
|
5105
|
+
# `jen api <path>` reaches it with the instance's own auth headers. One
|
|
5118
5106
|
# `tree=` query returns a whole history — 4855 bytes for five builds —
|
|
5119
5107
|
# so this costs one round trip like the GitHub arm does.
|
|
5120
5108
|
#
|
|
5121
|
-
#
|
|
5122
|
-
# the transport it had. What changed is the transport, not the rule.
|
|
5123
|
-
# The fetch, credential and match rule live in `jenkins_sha_runs`, which
|
|
5109
|
+
# THE FETCH AND MATCH RULE LIVE IN `jenkins_sha_runs`, which
|
|
5124
5110
|
# `runs-for-sha` shares. `|| exit $?` keeps exit 3 (no instance) apart
|
|
5125
5111
|
# from exit 4 (cannot be asked).
|
|
5126
5112
|
_jen_all=$(jenkins_sha_runs "$op" "$branch" "$limit" "$sha") || exit $?
|