Skip to content

Abstract task and nested tasks #1796

@startxfr

Description

@startxfr

Expected Behavior

Is there a way to use a task in a task. I couldn't find any documentation or information on how to use call a task in a task.

Actual Behavior

Task are only composed of a set of container execution. Is there a way to embed a task in another task. This could be powerfull to create "abstract" task that can be use into higher level task. Workspace, volume, env and stepTemplate heritage could be hard to handle.

Steps to Reproduce the Problem

More a enhancement rather than a problem

Additional Info

Abstract task example

This task could also be used directly in a pipeline, or a taskRun. It is called abstract in this example for the demonstration purpose.

apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: abstract-task
spec:
  params:
      - name: myParam
        type: string
        description: Default param from abstract task
        default: my abstract string from abstract task
      - name: myAbstractParam
        type: string
        description: Default param from abstract task
        default: my string from abstract task
      - name: myAbstract2Param
        type: string
        description: Default param from abstract2 task
        default: my string from abstract2 task
  steps:
    - name: "abstract-task"
      image: gcr.io/example-builders/build-example
      command: ["echo"]
      args: 
        - "abstract task - ",
          "myParam : ",
          "$(inputs.params.myParam)",
          "myAbstractParam : ",
          "$(inputs.params.myAbstractParam)"
          "myAbstractParam2 : ",
          "$(inputs.params.myAbstract2Param)"

Instanciable task example

apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: instanciable-task
spec:
  params:
      - name: myParam
        type: string
        description: Default param from instanciable task
        default: my param string from instanciable task
      - name: myInstanciableParam
        type: string
        description: Default param from instanciable task
        default: my string from instanciable task
  steps: 
      - name: "instanciable-task"
      taskRef:
        name: abstract-task
      inputs:
         params:
           - name: myParam
             value: "$(inputs.params.myParam)"
           - name: myAbstract2Param
             value: "$(inputs.params.myInstanciableParam)"

Pipeline example

apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
  name: pipeline-with-instanciable-and-abstract
spec:
  params:
    - name: myParam
      type: string
      description: Default param from pipeline task
      default: my param string from pipeline task
  tasks:
    - name: instanciable-task
      taskRef:
        name: instanciable-task
      params:
        - name: myParam
          value: "$(params.myParam)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.kind/questionIssues or PRs that are questions around the project or a particular featurelifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions