Files
Deploy-Laboratory/ansible/files/05-04/gitlab-ci-minimal.example.yml
2026-03-27 16:58:41 +08:00

22 lines
804 B
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# docs/05-04-k3s-配置gitlab-cicd.md — 最小 .gitlab-ci.yml 示例
stages: # CI 阶段定义(按顺序执行)
- lint # 代码/清单检查阶段
- deploy # 部署阶段
variables: # 全局变量
KUBECONFIG: "/builds/${CI_PROJECT_PATH}/kubeconfig" # Runner 内 kubeconfig 输出路径
lint: # 任务名lint
stage: lint # 归属 lint 阶段
script: # 执行脚本
- yamllint manifests || true # 允许 lint 失败不中断(示例用途)
deploy: # 任务名deploy
stage: deploy # 归属 deploy 阶段
script: # 执行脚本
- echo "$KUBE_CONFIG_CONTENT" > "$KUBECONFIG" # 将 CI 变量写入 kubeconfig 文件
- kubectl --kubeconfig="$KUBECONFIG" apply -f manifests/ # 应用 manifests
only: # 触发条件(旧语法)
- main # 仅 main 分支触发