Conditions just like Tasks should support script.
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"
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
/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
Most helpful comment
I can't think of a reason not to do this :) Script mode everywhere!