场景介绍
我们在上一篇文章中构建了一个最简单的ci,接下来我们对我们的github的项目构建一个较标准的ci。
ci是持续集成,我们只需要考虑部署前的事情:
pipeline:
- clone repo
- run test
- build image
- push image
有了这个思路,我们就把它们实现。 我们按照最简单ci/cd的步骤先写task, taskrun,然后写pipeline, pipelinerun。
构建ci
task git-clone
# task-clone.yaml
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: git-clone
labels:
app.kubernetes.io/version: "0.8"
spec:
workspaces:
- name: output
description: The git repo will be cloned into the dir
params:
- name: url
description: Repository URL to clone from.
type: string
- name: revision
description: which commit you would like to get, master or others
type: string
- name: base_image
description: base_image for git & unit testing
type: string
steps:
- name: clone
image: "$(params.base_image)"
env:
- name: WORKSPACE_OUTPUT_PATH
value: $(workspaces.output.path)
- name: GIT_REPO_URL
value: $(params.url)
- name: GIT_REPO_REVISION
value: $(params.revision)
script: |
#!/usr/bin/env sh
set -eu
whoami
pwd
cd ${WORKSPACE_OUTPUT_PATH}
pwd
rm -rf *
git clone ${GIT_REPO_URL}
repo_dir=$(echo $GIT_REPO_URL | rev | cut -d '/' -f 1 | rev | sed 's/.git//g')
cd ${repo_dir}
pwd
git checkout ${GIT_REPO_REVISION}
ls -al
pipeline & pipelinerun for git-clone
# pi

最低0.47元/天 解锁文章
511

被折叠的 条评论
为什么被折叠?



