fix: show agentrun pipelinerun condition message
This commit is contained in:
@@ -113,6 +113,7 @@ async function status(config: UniDeskConfig): Promise<Record<string, unknown>> {
|
|||||||
const argo = parseArgoStatus(k3s.stdout);
|
const argo = parseArgoStatus(k3s.stdout);
|
||||||
const mirror = await gitMirrorStatus(config);
|
const mirror = await gitMirrorStatus(config);
|
||||||
const ciSummary = labeledJson(k3s.stdout, "ciSummary");
|
const ciSummary = labeledJson(k3s.stdout, "ciSummary");
|
||||||
|
const pipelineRunCondition = labeledJson(k3s.stdout, "pipelineRunCondition");
|
||||||
return {
|
return {
|
||||||
ok: source.exitCode === 0 && k3s.exitCode === 0 && mirror.ok === true,
|
ok: source.exitCode === 0 && k3s.exitCode === 0 && mirror.ok === true,
|
||||||
command: "agentrun v01 control-plane status",
|
command: "agentrun v01 control-plane status",
|
||||||
@@ -125,6 +126,7 @@ async function status(config: UniDeskConfig): Promise<Record<string, unknown>> {
|
|||||||
expectedPipelineRun: pipelineRun,
|
expectedPipelineRun: pipelineRun,
|
||||||
source: compactCapture(source),
|
source: compactCapture(source),
|
||||||
runtime: compactCapture(k3s),
|
runtime: compactCapture(k3s),
|
||||||
|
pipelineRunCondition,
|
||||||
ciSummary,
|
ciSummary,
|
||||||
gitMirror: {
|
gitMirror: {
|
||||||
ok: mirror.ok,
|
ok: mirror.ok,
|
||||||
@@ -291,6 +293,26 @@ function statusScript(pipelineRun: string | null): string {
|
|||||||
pr.length > 0
|
pr.length > 0
|
||||||
? `kubectl -n ${ciNamespace} get pipelinerun ${shQuote(pr)} -o 'jsonpath={.metadata.name}{\"\\t\"}{.status.conditions[0].status}{\"\\t\"}{.status.conditions[0].reason}{\"\\t\"}{.status.startTime}{\"\\t\"}{.status.completionTime}{\"\\n\"}' 2>/dev/null || true`
|
? `kubectl -n ${ciNamespace} get pipelinerun ${shQuote(pr)} -o 'jsonpath={.metadata.name}{\"\\t\"}{.status.conditions[0].status}{\"\\t\"}{.status.conditions[0].reason}{\"\\t\"}{.status.startTime}{\"\\t\"}{.status.completionTime}{\"\\n\"}' 2>/dev/null || true`
|
||||||
: "true",
|
: "true",
|
||||||
|
"printf 'pipelineRunCondition='",
|
||||||
|
pr.length > 0
|
||||||
|
? [
|
||||||
|
`if kubectl -n ${ciNamespace} get pipelinerun ${shQuote(pr)} -o json >/tmp/agentrun-v01-pipelinerun.json 2>/dev/null; then`,
|
||||||
|
"node <<'NODE'",
|
||||||
|
"const fs = require('node:fs');",
|
||||||
|
"const pr = JSON.parse(fs.readFileSync('/tmp/agentrun-v01-pipelinerun.json', 'utf8'));",
|
||||||
|
"const condition = pr?.status?.conditions?.[0] || {};",
|
||||||
|
"console.log(JSON.stringify({",
|
||||||
|
" name: pr?.metadata?.name || null,",
|
||||||
|
" status: condition.status || null,",
|
||||||
|
" reason: condition.reason || null,",
|
||||||
|
" message: condition.message || null,",
|
||||||
|
" startTime: pr?.status?.startTime || null,",
|
||||||
|
" completionTime: pr?.status?.completionTime || null",
|
||||||
|
"}));",
|
||||||
|
"NODE",
|
||||||
|
"else printf '{}\\n'; fi",
|
||||||
|
].join("\n")
|
||||||
|
: "printf '{}\\n'",
|
||||||
"printf 'taskRuns\\n'",
|
"printf 'taskRuns\\n'",
|
||||||
pr.length > 0
|
pr.length > 0
|
||||||
? `kubectl -n ${ciNamespace} get taskrun -l tekton.dev/pipelineRun=${shQuote(pr)} -o 'custom-columns=NAME:.metadata.name,STATUS:.status.conditions[0].status,REASON:.status.conditions[0].reason,START:.status.startTime,COMPLETION:.status.completionTime' --no-headers 2>/dev/null || true`
|
? `kubectl -n ${ciNamespace} get taskrun -l tekton.dev/pipelineRun=${shQuote(pr)} -o 'custom-columns=NAME:.metadata.name,STATUS:.status.conditions[0].status,REASON:.status.conditions[0].reason,START:.status.startTime,COMPLETION:.status.completionTime' --no-headers 2>/dev/null || true`
|
||||||
|
|||||||
Reference in New Issue
Block a user