tekton构建标准ci(clone repo, test, build & push img)

场景介绍

我们在上一篇文章中构建了一个最简单的ci,接下来我们对我们的github的项目构建一个较标准的ci。

Tekton简介,安装和构建最简单ci/cd-优快云博客文章浏览阅读239次,点赞2次,收藏2次。本文介绍了tekton是什么,如何安装,以及实践了下task和task runhttps://blog.youkuaiyun.com/solinger/article/details/141898338?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22141898338%22%2C%22source%22%3A%22solinger%22%7D

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
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值