Parameterizing pipelines
Just like with tasks, you can add parameters to your Tekton pipelines. Those parameters would then typically be used as parameters for the tasks inside of them. By using parameters in your pipelines, you will reuse the same pipeline for multiple usages. For example, if you had a CI/CD pipeline to compile a Java application, you could reuse that pipeline across all of your projects, as long as the URL of the Git repository is a parameter.
In this next example, you will rewrite the tasks and pipeline from the last section, but this time keeping reusability in mind:
- First, create a new file called
die-roll-param.yaml
and copy over the content fromdie-roll.yaml
. - Next, add a parameter for the number of sides for the dice you want to roll. This parameter will be of the
string
type. You can also add adefault
value of"6"
. This parameter takes a string as an argument, so don't forget the quotes around thedefault
value:...