以下介绍的是基于 Gitee 仓库 的 Tekton 工作流程
操作流程
定义task
克隆代码的task
# task-clone.yaml
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:name: git-clone
spec:workspaces:- name: source # 工作目录params:- name: repo-url # 你的 Gitee 仓库地址type: stringdefault: "https://gitee.com/wyxsxx/wyx123.git"- name: branch # 分支名称type: stringdefault: "main"steps:- name: cloneimage: alpine/git # 使用轻量级 Git 镜像script: |git clone -b $(params.branch) $(params.repo-url) $(workspaces.source.path)/app
执行自定义脚本的 Task
# task-script.yaml
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:name: run-script
spec:workspaces:- name: sourcesteps:- name: run-custom-scriptimage: alpine:3.15 # 按需替换为 Python/Node.js 等镜像workingDir: "$(workspaces.source.path)/app"script: |# 这里执行你的自定义脚本(示例:打印文件列表)echo "=== 文件列表 ==="ls -lecho "==============="
定义 Pipeline
# pipeline.yaml
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:name: simple-demo-pipeline
spec:worksp