You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.2 KiB
80 lines
2.2 KiB
2 years ago
|
apiVersion: tekton.dev/v1beta1
|
||
|
kind: Pipeline
|
||
|
metadata:
|
||
|
name: cat-branch-readme
|
||
|
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.
|
||
|
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-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: cat-readme
|
||
|
runAfter: ["fetch-repo"] # Wait until the clone is done before reading the readme.
|
||
|
workspaces:
|
||
|
- name: source
|
||
|
workspace: shared-data
|
||
|
taskSpec:
|
||
|
workspaces:
|
||
|
- name: source
|
||
|
steps:
|
||
|
- image: zshusers/zsh:4.3.15
|
||
|
script: |
|
||
|
#!/usr/bin/env zsh
|
||
|
cat $(workspaces.source.path)/README.md
|
||
|
---
|
||
|
apiVersion: tekton.dev/v1beta1
|
||
|
kind: PipelineRun
|
||
|
metadata:
|
||
|
name: git-clone-checking-out-a-branch
|
||
|
spec:
|
||
|
serviceAccountName: build-bot
|
||
|
pipelineRef:
|
||
|
name: cat-branch-readme
|
||
|
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.git
|
||
|
- name: branch-name
|
||
|
value: master
|