Skip to content

Instantly share code, notes, and snippets.

View pritidesai's full-sized avatar
🥂

Priti Desai pritidesai

🥂
View GitHub Profile
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: sum-two-ints
annotations:
description: |
A simple task that sums the two provided integers
spec:
params:
- name: a
{
"apiVersion": "tekton.dev/v1beta1",
"kind": "TaskRun",
"metadata": {
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"tekton.dev/v1beta1\",\"kind\":\"Task\",\"metadata\":{\"annotations\":{},\"name\":\"successful-task\",\"namespace\":\"default\"},\"spec\":{\"steps\":[{\"image\":\"ubuntu\",\"name\":\"success\",\"script\":\"exit 0\\n\"}]}}\n",
"pipeline.tekton.dev/release": "devel"
},
"creationTimestamp": "2020-04-23T01:38:24Z",
"generation": 1,
{
"apiVersion": "tekton.dev/v1beta1",
"kind": "TaskRun",
"metadata": {
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"tekton.dev/v1beta1\",\"kind\":\"Task\",\"metadata\":{\"annotations\":{},\"name\":\"successful-task\",\"namespace\":\"default\"},\"spec\":{\"steps\":[{\"image\":\"ubuntu\",\"name\":\"success\",\"script\":\"exit 0\\n\"}]}}\n",
"pipeline.tekton.dev/release": "devel"
},
"creationTimestamp": "2020-04-23T01:38:52Z",
"generation": 1,

Refactor PipelineTask Struct

The final tasks are similar to regular non-final tasks and can be declared as PipelineTask. The only caveat here is final tasks do not allow two fields RunAfter and Conditions compared to non-final tasks.There are two different options to address that.

Option 1

Declare final task as PipelineTask but add validation to not allow runAfter and conditions.

Pros:

### With Nested Pipeline and Pipeline Level except/finally
# test pipeline
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
name: deploy-pipeline
spec:
tasks:
- name: pre-work
### With Nested Pipeline and Pipeline Level except/finally
# test pipeline
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
name: test-pipeline
spec:
tasks:
- name: unit-tests
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
name: my-pipeline
spec:
tasks:
- name: unit-tests
taskRef:
Name: uts
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: my-pipeline
spec:
params:
- name: APP_PATH
type: string
default: ""
tasks:
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: test-pipeline
spec:
tasks:
- name: pre-work
taskRef:
Name: pre-work
- name: unit-test
(v1beta1.PipelineRunStatus) {
Status: (v1beta1.Status) {
ObservedGeneration: (int64) 0,
Conditions: (v1beta1.Conditions) (len=1 cap=1) {
(apis.Condition) {
Type: (apis.ConditionType) (len=9) "Succeeded",
Status: (v1.ConditionStatus) (len=4) "True",
Severity: (apis.ConditionSeverity) "",
LastTransitionTime: (apis.VolatileTime) {
Inner: (v1.Time) 2020-03-31 17:10:53.6440927 +0000 UTC m=+301.304660801