apiVersion: tekton.dev/v1beta1 kind: Pipeline metadata: name: deploy spec: description: | cat-branch-readme takes a git repository and a branch name and prints the README.md file from that branch. This is an example Pipeline demonstrating the following: - Using the git-clone catalog Task to clone a branch - Passing a cloned repo to subsequent Tasks using a Workspace. - Ordering Tasks in a Pipeline using "runAfter" so that git-clone completes before we try to read from the Workspace. - Using a volumeClaimTemplate Volume as a Workspace. - Avoiding hard-coded paths by using a Workspace's path variable instead. params: - name: repo-url type: string description: The git repository URL to clone from. - name: branch-name type: string description: The git branch to clone. - name: app-name type: string description: The app name. - name: image-name type: string description: The image - name: image-tag type: string description: The image tag workspaces: - name: shared-data description: | This workspace will receive the cloned git repo and be passed to the next Task for the repo's README.md file to be read. tasks: - name: fetch-deploy-repo taskRef: name: git-clone workspaces: - name: output workspace: shared-data params: - name: url value: $(params.repo-url) - name: revision value: $(params.branch-name) - name: commit-deploy-image runAfter: - fetch-deploy-repo params: - name: image-name value: $(params.image-name) - name: image-tag value: $(params.image-tag) - name: git-branch value: $(params.branch-name) workspaces: - name: source workspace: shared-data taskSpec: params: - name: image-name - name: image-tag - name: git-branch workspaces: - name: source steps: - image: alpine/git:v2.36.2 script: | #!/usr/bin/env sh cd $(workspaces.source.path) git config --global --add safe.directory $(workspaces.source.path) git checkout -b $(params.git-branch) sed -i "s#newName: .*#newName: $(params.image-name)#" manager/kustomization.yaml sed -i "s#newTag: .*#newTag: $(params.image-tag)#" manager/kustomization.yaml git config --global user.email "tekton-rebot@mashibing.com" git config --global user.name "tekton rebot" git add manager/kustomization.yaml git commit -m "update image to $(params.image-name):$(params.image-tag)" git push origin master - name: sync-application runAfter: - commit-deploy-image taskRef: name: argocd-task-sync-and-wait params: - name: application-name value: $(params.app-name) - name: flags value: --insecure - name: argocd-version value: latest --- apiVersion: tekton.dev/v1beta1 kind: PipelineRun metadata: name: deploy spec: serviceAccountName: build-bot pipelineRef: name: deploy podTemplate: securityContext: fsGroup: 65532 workspaces: - name: shared-data volumeClaimTemplate: spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi params: - name: repo-url value: git@host.docker.internal:root/mashibing-deployment-deploy.git - name: branch-name value: master - name: app-name value: msb-app - name: image-name value: kind-registry:5000/deployment/msbdeployment - name: image-tag value: v0.0.2