Skip to content

Commit

Permalink
Adds an initial implementation for conditionals
Browse files Browse the repository at this point in the history
In this implementation, condition evaluations aka ConditionChecks are
backed by TaskRuns. All conditionChecks associated with a `PipelineTask`
have to succeed before the task is executed. If a ConditionCheck fails,
the PipelineTask's associated TaskRun is marked failed i.e. its
`Status.ConditionSucceeded` is False. However, the PipelineRun itself
is not marked as failed.
  • Loading branch information
dibyom committed Jul 2, 2019
1 parent e96975e commit 27bb8d4
Show file tree
Hide file tree
Showing 11 changed files with 1,290 additions and 79 deletions.
2 changes: 2 additions & 0 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func main() {
taskRunInformer := pipelineInformerFactory.Tekton().V1alpha1().TaskRuns()
resourceInformer := pipelineInformerFactory.Tekton().V1alpha1().PipelineResources()
podInformer := kubeInformerFactory.Core().V1().Pods()
conditionInformer := pipelineInformerFactory.Tekton().V1alpha1().Conditions()

pipelineInformer := pipelineInformerFactory.Tekton().V1alpha1().Pipelines()
pipelineRunInformer := pipelineInformerFactory.Tekton().V1alpha1().PipelineRuns()
Expand All @@ -134,6 +135,7 @@ func main() {
clusterTaskInformer,
taskRunInformer,
resourceInformer,
conditionInformer,
timeoutHandler,
)
// Build all of our controllers, with the clients constructed above.
Expand Down
77 changes: 77 additions & 0 deletions examples/pipelineruns/conditional-pipelinerun.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
apiVersion: tekton.dev/v1alpha1
kind: Condition
metadata:
# General purpose condition for checking if a file exists at the given
name: always-true
spec:
check:
# Check is a container spec describing the container to be run to
# check the condition
image: ubuntu
command: ["/bin/bash"]
args: ['-c', 'ls']
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: fiat-git
spec:
type: git
params:
- name: revision
value: master
- name: url
value: https://github.com/spinnaker/fiat
---
#Builds an image via kaniko and pushes it to registry.
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: list-files
spec:
inputs:
resources:
- name: workspace
type: git
steps:
- name: run-ls
image: ubuntu
command: ["/bin/bash"]
args: ['-c', 'ls -al ${inputs.resources.workspace.path}']
---
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
name: list-files-pipeline
spec:
resources:
- name: source-repo
type: git
tasks:
- name: list-files
taskRef:
name: list-files
conditions:
- conditionRef: always-true
# params:
# - name: expected
# value: master
# - name: actual
# value: ${input.workspace.revision}
resources:
inputs:
- name: workspace
resource: source-repo
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
name: demo-pr
spec:
pipelineRef:
name: list-files-pipeline
serviceAccount: 'default'
resources:
- name: source-repo
resourceRef:
name: fiat-git
13 changes: 7 additions & 6 deletions pkg/apis/pipeline/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package pipeline

// GroupName is the Kubernetes resource group name for Pipeline types.
const (
GroupName = "tekton.dev"
TaskLabelKey = "/task"
TaskRunLabelKey = "/taskRun"
PipelineLabelKey = "/pipeline"
PipelineRunLabelKey = "/pipelineRun"
PipelineTaskLabelKey = "/pipelineTask"
GroupName = "tekton.dev"
TaskLabelKey = "/task"
TaskRunLabelKey = "/taskRun"
PipelineLabelKey = "/pipeline"
PipelineRunLabelKey = "/pipelineRun"
PipelineTaskLabelKey = "/pipelineTask"
PipelineRunConditionCheckKey = "/pipelineConditionCheck"
)
Loading

0 comments on commit 27bb8d4

Please sign in to comment.