fix: trigger branch followers natively

This commit is contained in:
Codex
2026-07-03 09:17:19 +00:00
parent 291e61e638
commit 0e75edd2c4
2 changed files with 410 additions and 23 deletions
+23 -19
View File
@@ -296,8 +296,30 @@ export async function runYamlLaneGitMirrorJob(config: UniDeskConfig, spec: Agent
}
export function yamlLanePipelineRunCreateScript(spec: AgentRunLaneSpec, sourceCommit: string, pipelineRun: string): string {
const manifest = yamlLanePipelineRunManifest(spec, sourceCommit, pipelineRun);
const manifestB64 = Buffer.from(JSON.stringify(manifest), "utf8").toString("base64");
return [
"set -eu",
`namespace=${shQuote(spec.ci.namespace)}`,
`pipeline_run=${shQuote(pipelineRun)}`,
`manifest_b64=${shQuote(manifestB64)}`,
"tmp=$(mktemp)",
"trap 'rm -f \"$tmp\"' EXIT",
"printf '%s' \"$manifest_b64\" | base64 -d > \"$tmp\"",
"existing_status=$(kubectl -n \"$namespace\" get pipelinerun \"$pipeline_run\" -o 'jsonpath={.status.conditions[0].status}' 2>/dev/null || true)",
"if [ \"$existing_status\" = False ]; then kubectl -n \"$namespace\" delete pipelinerun \"$pipeline_run\" --ignore-not-found=true --wait=false >/dev/null 2>&1 || true; fi",
"if kubectl -n \"$namespace\" get pipelinerun \"$pipeline_run\" >/dev/null 2>&1; then created=false; else kubectl create -f \"$tmp\"; created=true; fi",
"status=$(kubectl -n \"$namespace\" get pipelinerun \"$pipeline_run\" -o 'jsonpath={.status.conditions[0].status}' 2>/dev/null || true)",
"CREATED=\"$created\" STATUS=\"$status\" PIPELINE_RUN=\"$pipeline_run\" python3 - <<'PY'",
"import json, os",
"print(json.dumps({'ok': True, 'pipelineRun': os.environ.get('PIPELINE_RUN'), 'created': os.environ.get('CREATED') == 'true', 'status': os.environ.get('STATUS') or None, 'valuesPrinted': False}, ensure_ascii=False))",
"PY",
].join("\n");
}
export function yamlLanePipelineRunManifest(spec: AgentRunLaneSpec, sourceCommit: string, pipelineRun: string): Record<string, unknown> {
const sourceStageRef = spec.source.statusMode === "k3s-git-mirror" ? agentRunSourceSnapshotRef(spec, sourceCommit) : null;
const manifest = {
return {
apiVersion: "tekton.dev/v1",
kind: "PipelineRun",
metadata: {
@@ -337,24 +359,6 @@ export function yamlLanePipelineRunCreateScript(spec: AgentRunLaneSpec, sourceCo
],
},
};
const manifestB64 = Buffer.from(JSON.stringify(manifest), "utf8").toString("base64");
return [
"set -eu",
`namespace=${shQuote(spec.ci.namespace)}`,
`pipeline_run=${shQuote(pipelineRun)}`,
`manifest_b64=${shQuote(manifestB64)}`,
"tmp=$(mktemp)",
"trap 'rm -f \"$tmp\"' EXIT",
"printf '%s' \"$manifest_b64\" | base64 -d > \"$tmp\"",
"existing_status=$(kubectl -n \"$namespace\" get pipelinerun \"$pipeline_run\" -o 'jsonpath={.status.conditions[0].status}' 2>/dev/null || true)",
"if [ \"$existing_status\" = False ]; then kubectl -n \"$namespace\" delete pipelinerun \"$pipeline_run\" --ignore-not-found=true --wait=false >/dev/null 2>&1 || true; fi",
"if kubectl -n \"$namespace\" get pipelinerun \"$pipeline_run\" >/dev/null 2>&1; then created=false; else kubectl create -f \"$tmp\"; created=true; fi",
"status=$(kubectl -n \"$namespace\" get pipelinerun \"$pipeline_run\" -o 'jsonpath={.status.conditions[0].status}' 2>/dev/null || true)",
"CREATED=\"$created\" STATUS=\"$status\" PIPELINE_RUN=\"$pipeline_run\" python3 - <<'PY'",
"import json, os",
"print(json.dumps({'ok': True, 'pipelineRun': os.environ.get('PIPELINE_RUN'), 'created': os.environ.get('CREATED') == 'true', 'status': os.environ.get('STATUS') or None, 'valuesPrinted': False}, ensure_ascii=False))",
"PY",
].join("\n");
}
export function createYamlLaneJobScript(namespace: string, jobName: string, manifest: Record<string, unknown>): string {