Exercise 8: Create a custom Tekton Task and Pipleline
In this exercise, we will show how to create Tekton artifacts, and how to plug into the existing pipelines and environment knowledge that Kabanero provides to those artifacts.
When you have completed this exercise, you will understand how to
create a custom Task in Tekton
create a custom Pipeline in Tekton
Tools used during Exercise 8
Prerequisites
You should have already carried out the prerequisites defined in Exercise 7.
In addition, recall how to do the following from Exercise 4
From completing the previous exercise you should now have a code base in the following folder
Should result in output that looks like the following:
We will now upload that code to Github.
Go to https://github.com/new and create a new repository, test-custom-stack. Do not initiatize the repos with a license file or README.
From your test-custom-stack directory, run the commands below, replacing <username> with your own.
The repo should look like this:
Repo code base
2. Create a custom Tekton Task
Create a new directory to iterate on new tasks
Create a new file named test-task.yaml with the following contents:
Run the following to create the Task in Tekton:
3. Create a custom Tekton Pipeline
Create a new file named test-pipeline.yaml with the following contents:
Run the following to create the Pipeline in Tekton:
4. Add a webhook to Tekton to watch Github for changes
From the Tekton dashboard, we need to add a new webhook. Launch a browser and access the dashboard.
To configure the GitHub webhook to your repo. Go to Webhooks > Add Webhook and then create the webhook.
new webhook options
Create a webhook for the backend
Return to your git repo and check the Settings > Webhooks panel to verify that the webhook has been added and is working.
5. Test it all out
In your test-custom-stack repo, change the file app.js. Change a value in the res.send("Hello from Appsody!"); function. Then commit this change and push to your github repo, for example:
This will trigger the tekton pipleine. Go to the tekton dashboard and access the new pipeline it created.