Files
pikasTech-HWLAB/deploy/gitops/g14/tekton/pipeline.yaml
T
2026-05-25 01:49:24 +08:00

327 lines
12 KiB
YAML

{
"apiVersion": "tekton.dev/v1",
"kind": "Pipeline",
"metadata": {
"name": "hwlab-g14-ci-image-publish",
"namespace": "hwlab-ci",
"labels": {
"app.kubernetes.io/part-of": "hwlab",
"hwlab.pikastech.local/gitops-target": "g14"
},
"annotations": {
"hwlab.pikastech.local/source-config": "CI.json",
"hwlab.pikastech.local/policy": "parallel-no-lock-ci-image-publish"
}
},
"spec": {
"params": [
{
"name": "git-url",
"type": "string",
"default": "git@github.com:pikasTech/HWLAB.git"
},
{
"name": "source-branch",
"type": "string",
"default": "G14"
},
{
"name": "revision",
"type": "string",
"description": "Full git commit SHA; the only source truth for image tags."
},
{
"name": "registry-prefix",
"type": "string",
"default": "127.0.0.1:5000/hwlab"
},
{
"name": "services",
"type": "string",
"default": "hwlab-cloud-api,hwlab-cloud-web,hwlab-agent-mgr,hwlab-agent-worker,hwlab-gateway,hwlab-gateway-simu,hwlab-box-simu,hwlab-patch-panel,hwlab-router,hwlab-tunnel-client,hwlab-edge-proxy,hwlab-cli,hwlab-agent-skills"
},
{
"name": "base-image",
"type": "string",
"default": "node:20-bookworm-slim"
},
{
"name": "concurrency",
"type": "string",
"default": "4"
}
],
"workspaces": [
{
"name": "source"
},
{
"name": "git-ssh"
}
],
"tasks": [
{
"name": "ci-json",
"workspaces": [
{
"name": "source",
"workspace": "source"
},
{
"name": "git-ssh",
"workspace": "git-ssh"
}
],
"taskSpec": {
"params": [
{
"name": "git-url"
},
{
"name": "source-branch"
},
{
"name": "revision"
}
],
"workspaces": [
{
"name": "source"
},
{
"name": "git-ssh"
}
],
"steps": [
{
"name": "ci-json",
"image": "mcr.microsoft.com/playwright:v1.59.1-noble",
"env": [
{
"name": "HTTP_PROXY",
"value": "http://127.0.0.1:10808"
},
{
"name": "HTTPS_PROXY",
"value": "http://127.0.0.1:10808"
},
{
"name": "ALL_PROXY",
"value": "socks5h://127.0.0.1:10808"
},
{
"name": "NO_PROXY",
"value": "127.0.0.1,localhost,::1,10.0.0.0/8,10.42.0.0/16,10.43.0.0/16,192.168.0.0/16,.svc,.cluster.local,kubernetes.default.svc,registry.hwlab-ci.svc,hwlab-registry.hwlab-ci.svc"
},
{
"name": "http_proxy",
"value": "http://127.0.0.1:10808"
},
{
"name": "https_proxy",
"value": "http://127.0.0.1:10808"
},
{
"name": "all_proxy",
"value": "socks5h://127.0.0.1:10808"
},
{
"name": "no_proxy",
"value": "127.0.0.1,localhost,::1,10.0.0.0/8,10.42.0.0/16,10.43.0.0/16,192.168.0.0/16,.svc,.cluster.local,kubernetes.default.svc,registry.hwlab-ci.svc,hwlab-registry.hwlab-ci.svc"
}
],
"script": "#!/bin/sh\nset -eu\nif ! command -v git >/dev/null 2>&1 || ! command -v python3 >/dev/null 2>&1 || ! command -v ssh >/dev/null 2>&1; then\n export DEBIAN_FRONTEND=noninteractive\n apt-get update\n apt-get install -y --no-install-recommends git python3 openssh-client ca-certificates\n rm -rf /var/lib/apt/lists/*\nfi\nmkdir -p /root/.ssh\ncp /workspace/git-ssh/ssh-privatekey /root/.ssh/id_rsa\nchmod 600 /root/.ssh/id_rsa\nssh-keyscan github.com >> /root/.ssh/known_hosts 2>/dev/null\nrm -rf /workspace/source/repo\ngit clone --branch \"$(params.source-branch)\" \"$(params.git-url)\" /workspace/source/repo\ncd /workspace/source/repo\ngit checkout \"$(params.revision)\"\ntest \"$(git rev-parse HEAD)\" = \"$(params.revision)\"\nnpm ci --ignore-scripts\nnpx playwright install chromium\necho 'CI.json hwlab-deploy-skeleton-ci command count=6'\necho 'CI.json command: repo-reports-guard'\nnode scripts/repo-reports-guard.mjs\necho 'CI.json command: contract-check'\nnpm run check\necho 'CI.json command: dev-artifact-publish-static-check'\nnode --check scripts/dev-artifact-publish.mjs\necho 'CI.json command: parse-deploy-json'\nnode -e \"JSON.parse(require('node:fs').readFileSync('deploy/deploy.json','utf8'))\"\necho 'CI.json command: parse-k8s-json-yaml'\nnode -e \"const fs=require('node:fs'); for (const f of fs.readdirSync('deploy/k8s/base').concat(fs.readdirSync('deploy/k8s/dev').map(x=>'../dev/'+x), fs.readdirSync('deploy/k8s/prod').map(x=>'../prod/'+x))) { if (!f.endsWith('.yaml')) continue; const p=f.startsWith('..')?'deploy/k8s/'+f.replace('../',''):'deploy/k8s/base/'+f; JSON.parse(fs.readFileSync(p,'utf8')); }\"\necho 'CI.json command: parse-frp-toml'\npython3 - <<'PY'\nimport pathlib, tomllib\nfor path in pathlib.Path('deploy/frp').glob('*.toml'):\n tomllib.loads(path.read_text())\nPY\n"
}
]
},
"params": [
{
"name": "git-url",
"value": "$(params.git-url)"
},
{
"name": "source-branch",
"value": "$(params.source-branch)"
},
{
"name": "revision",
"value": "$(params.revision)"
}
]
},
{
"name": "image-publish",
"runAfter": [
"ci-json"
],
"workspaces": [
{
"name": "source",
"workspace": "source"
}
],
"taskSpec": {
"params": [
{
"name": "revision"
},
{
"name": "registry-prefix"
},
{
"name": "services"
},
{
"name": "base-image"
},
{
"name": "concurrency"
}
],
"workspaces": [
{
"name": "source"
}
],
"volumes": [
{
"name": "docker-run",
"emptyDir": {}
}
],
"sidecars": [
{
"name": "docker",
"image": "docker:29-dind",
"args": [
"--host=unix:///var/run/docker.sock",
"--storage-driver=vfs"
],
"env": [
{
"name": "DOCKER_TLS_CERTDIR",
"value": ""
},
{
"name": "HTTP_PROXY",
"value": "http://127.0.0.1:10808"
},
{
"name": "HTTPS_PROXY",
"value": "http://127.0.0.1:10808"
},
{
"name": "ALL_PROXY",
"value": "socks5h://127.0.0.1:10808"
},
{
"name": "NO_PROXY",
"value": "127.0.0.1,localhost,::1,10.0.0.0/8,10.42.0.0/16,10.43.0.0/16,192.168.0.0/16,.svc,.cluster.local,kubernetes.default.svc,registry.hwlab-ci.svc,hwlab-registry.hwlab-ci.svc"
},
{
"name": "http_proxy",
"value": "http://127.0.0.1:10808"
},
{
"name": "https_proxy",
"value": "http://127.0.0.1:10808"
},
{
"name": "all_proxy",
"value": "socks5h://127.0.0.1:10808"
},
{
"name": "no_proxy",
"value": "127.0.0.1,localhost,::1,10.0.0.0/8,10.42.0.0/16,10.43.0.0/16,192.168.0.0/16,.svc,.cluster.local,kubernetes.default.svc,registry.hwlab-ci.svc,hwlab-registry.hwlab-ci.svc"
}
],
"securityContext": {
"privileged": true
},
"volumeMounts": [
{
"name": "docker-run",
"mountPath": "/var/run"
}
]
}
],
"steps": [
{
"name": "publish",
"image": "node:22-alpine",
"env": [
{
"name": "DOCKER_HOST",
"value": "unix:///var/run/docker.sock"
},
{
"name": "HTTP_PROXY",
"value": "http://127.0.0.1:10808"
},
{
"name": "HTTPS_PROXY",
"value": "http://127.0.0.1:10808"
},
{
"name": "ALL_PROXY",
"value": "socks5h://127.0.0.1:10808"
},
{
"name": "NO_PROXY",
"value": "127.0.0.1,localhost,::1,10.0.0.0/8,10.42.0.0/16,10.43.0.0/16,192.168.0.0/16,.svc,.cluster.local,kubernetes.default.svc,registry.hwlab-ci.svc,hwlab-registry.hwlab-ci.svc"
},
{
"name": "http_proxy",
"value": "http://127.0.0.1:10808"
},
{
"name": "https_proxy",
"value": "http://127.0.0.1:10808"
},
{
"name": "all_proxy",
"value": "socks5h://127.0.0.1:10808"
},
{
"name": "no_proxy",
"value": "127.0.0.1,localhost,::1,10.0.0.0/8,10.42.0.0/16,10.43.0.0/16,192.168.0.0/16,.svc,.cluster.local,kubernetes.default.svc,registry.hwlab-ci.svc,hwlab-registry.hwlab-ci.svc"
}
],
"volumeMounts": [
{
"name": "docker-run",
"mountPath": "/var/run"
}
],
"script": "#!/bin/sh\nset -eu\napk add --no-cache docker-cli git openssh-client python3\nexport DOCKER_HOST=unix:///var/run/docker.sock\nexport HWLAB_CI_ARTIFACT_RUN_ID=\"$(context.pipelineRun.name)\"\nexport HWLAB_CI_ARTIFACT_RUN_OWNER=\"tekton\"\nexport HWLAB_DEV_REGISTRY_PREFIX=\"$(params.registry-prefix)\"\nexport HWLAB_DEV_REGISTRY_K8S_NATIVE=1\nif [ -n \"$(params.base-image)\" ]; then export HWLAB_DEV_BASE_IMAGE=\"$(params.base-image)\"; fi\nfor i in $(seq 1 90); do docker info >/dev/null 2>&1 && break; sleep 2; done\ndocker info >/dev/null\ncd /workspace/source/repo\ntest \"$(git rev-parse HEAD)\" = \"$(params.revision)\"\nnode scripts/dev-artifact-publish.mjs --publish --registry-prefix \"$(params.registry-prefix)\" --report /workspace/source/dev-artifacts.json --quiet-build --concurrency \"$(params.concurrency)\" --services \"$(params.services)\"\nnode scripts/refresh-artifact-catalog.mjs --target-ref HEAD --publish-report /workspace/source/dev-artifacts.json --no-write\n"
}
]
},
"params": [
{
"name": "revision",
"value": "$(params.revision)"
},
{
"name": "registry-prefix",
"value": "$(params.registry-prefix)"
},
{
"name": "services",
"value": "$(params.services)"
},
{
"name": "base-image",
"value": "$(params.base-image)"
},
{
"name": "concurrency",
"value": "$(params.concurrency)"
}
]
}
]
}
}