CS472 - CI - Building a Tekton Pipeline
In this lab, you will build Tekton pipeline.
Task 1 - Create a simple Tekton pipeline
- Clone the code you need to test and change directory to
wtecc-CICD_PracticeCode/labs/01_base_pipeline/git clone https://github.com/ibm-developer-skills-network/wtecc-CICD_PracticeCode.gitNavigate to the labs/01_base_pipeline folder. All of your work will be completed with the files in this folder.
- There is starter code in the
labs/01_base_pipelinefolder for a task and a pipeline. Navigate and open thetasks.yamlfile to edit it:apiVersion: tekton.dev/v1beta1 kind: Task metadata: name: <place-name-here> spec: steps:- The first thing you want to do is give the task a good name. Change
<place-name-here>tohello-world. - The next thing is to add a step. The steps that run a single command need to include
name,image,command, andargs. Make the nameecho, use the imagealpine:3, have the command be[/bin/echo]and the args be["Hello World"].spec: steps: - name: echo image: alpine:3 command: [/bin/echo] args: ["Hello World!"] - Apply the task to the cluster using the following command:
kubectl apply -f tasks.yaml
- The first thing you want to do is give the task a good name. Change
- Create a hello-pipeline Pipeline
```yaml
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: hello-pipeline
spec:
tasks:
- name: hello taskRef: name: hello-world ```
- Apply it to the cluster using the following command:
kubectl apply -f pipeline.yaml - You are now ready to run your pipeline and see if it works.
- Run the hello-pipeline
- Run the pipeline using the Tekton CLI:
tkn pipeline start --showlog hello-pipeline - You should see the output:
PipelineRun started: hello-pipeline-run-9vkbb Waiting for logs to be available... [hello : echo] Hello World!
- Run the pipeline using the Tekton CLI: