pipeline icon indicating copy to clipboard operation
pipeline copied to clipboard

Increase Task Reuse

Open S9n3x opened this issue 1 year ago • 4 comments

Feature request

It would be beneficial to introduce a taskRef option in the creation of a Task to facilitate the reuse of certain features of a Task where the variations may simply be one parameter, to avoid the complexity of repeatedly inputting parameters. For instance, in sending notifications, most of the server information may remain the same and the only difference would typically be the message content. Entering these parameters for every task creation is cumbersome. Of course, one can create a task with fixed values and then invoke this Task, but this approach may be too complicated for beginners. Additionally, if some tasks are installed from hub.tekton.dev, altering their YAML configurations could also necessitate an understanding of their internal purposes, thus involving a learning cost.

Use case

I hope

apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: notice-host-1
spec:
  params:
    - name: server
      value: host.com
    - name: port
      value: 8080
    - name: token
      value: "xxxxxxxxxxxxxxxxxxxxxx"
    - name: msg
  taskRef:
    name: notice

S9n3x avatar May 27 '24 01:05 S9n3x

You can specify a default value for each param: https://tekton.dev/docs/pipelines/tasks/#default-value

If no value is provided for that param at runtime (via TaskRun / PipelineRun) then the default value is used.

Also if you're using Tekton Triggers you can specify param values in your TriggerTemplate / TriggerBinding to avoid the need to provide them each time.

AlanGreene avatar May 27 '24 10:05 AlanGreene

You can specify a default value for each param: https://tekton.dev/docs/pipelines/tasks/#default-value

If no value is provided for that param at runtime (via TaskRun / PipelineRun) then the default value is used.

Also if you're using Tekton Triggers you can specify param values in your TriggerTemplate / TriggerBinding to avoid the need to provide them each time.

Although default values can be used to solve the problem I raised, some Task exist in hub.tekton.dev, and some ordinary users may have some learning costs to modify these values. Adding the features I mentioned would be more convenient for users to use

S9n3x avatar May 27 '24 12:05 S9n3x

You can also specify default values in your Pipeline, so consumers of the Pipeline do not need to be aware of the individual Task config, but can still override the values you provide if they wish.

AlanGreene avatar May 28 '24 09:05 AlanGreene

You can also specify default values in your Pipeline, so consumers of the Pipeline do not need to be aware of the individual Task config, but can still override the values you provide if they wish.

If I set these duplicate values in the pipeline, I will need to configure certain parameters repeatedly for each of my multiple pipelines, which is too troublesome. I hope to configure the fixed values of the task task before creating the pipeline, so that the configuration of each pipeline will be very convenient for me

S9n3x avatar May 29 '24 00:05 S9n3x