Pipeline: enable script for conditions

Created on 5 Dec 2019  Â·  4Comments  Â·  Source: tektoncd/pipeline

Expected Behavior

Conditions just like Tasks should support script.

Actual Behavior

Deployment fails with:

Error from server (InternalError): error when creating "examples/pipelineruns/conditional-pipelinerun-with-optional-resources.yaml": Internal error occurred: admission webhook "webhook.tekton.dev" denied the request: mutation failed: cannot decode incoming new object: json: unknown field "script"

Steps to Reproduce the Problem

While working on PR # 1601, discovered script is not supported by Condition resources:

kubectl apply -f examples/pipelineruns/conditional-pipelinerun-with-optional-resources.yaml

Here is the YAML content of the pipeline:

apiVersion: tekton.dev/v1alpha1
kind: Condition
metadata:
  name: verify-no-file-exists-without-resource
spec:
  params:
    - name: "path"
  resources:
    - name: optional-workspace
      type: git
      optional: true
  check:
    image: alpine
    script: |
      #!/bin/sh
      test ! -f $(resources.optional-workspace.path)/$(params.path)
---

apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
  name: pipeline-git-repo
spec:
  type: git
  params:
    - name: revision
      value: master
    - name: url
      value: https://github.com/tektoncd/pipeline
---

apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: list-pipeline-repo-files
spec:
  inputs:
    resources:
      - name: optional-workspace
        type: git
        optional: true
  steps:
    - name: run-ls
      image: ubuntu
      script: |
        #!/bin/bash
        ls -al $(inputs.resources.optional-workspace.path)
---

apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
  name: pipeline-list-pipeline-repo-files
spec:
  resources:
    - name: pipeline-source-repo
      type: git
  params:
    - name: "path"
      default: "README.md"
  tasks:
    - name: list-pipeline-repo-files-1
      taskRef:
        name: list-pipeline-repo-files
      conditions:
        - conditionRef: "verify-no-file-exists-without-resource"
          params:
            - name: "path"
              value: "$(params.path)"
#          NOTE: Resource "optional-workspace" is declared as optional in Condition
#          No resource specified for the condition here since its optional
#          "DO NOT UNCOMMENT THE FOLLOWING RESOURCE"
#          resources:
#            - name: optional-workspace
#              resource: pipeline-source-repo
      resources:
        inputs:
          - name: optional-workspace
            resource: pipeline-source-repo
---

apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
  name: demo-condtional-pr-without-condition-resource
spec:
  pipelineRef:
    name: pipeline-list-pipeline-repo-files
  serviceAccount: 'default'
  resources:
    - name: pipeline-source-repo
      resourceRef:
        name: pipeline-git-repo

Additional Info

areapi good first issue help wanted kinfeature

Most helpful comment

I can't think of a reason not to do this :) Script mode everywhere!

All 4 comments

/kind feature
/area api
/cc @dibyom @ImJasonH

I can't think of a reason not to do this :) Script mode everywhere!

If nobody is currently working on it, I will be happy to create PR with such change :)

/assign @cezkuj

Was this page helpful?
0 / 5 - 0 ratings