Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: pip-parent
spec:
tasks:
- name: pip-child
pipelineSpec:
tasks:
- name: pip-child-task
taskSpec:
steps:
- name: hello-pip
image: mirror.gcr.io/alpine
script: echo "Hello from pip!"
---
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
generateName: pip-parent-run-
spec:
pipelineRef:
name: pip-parent
10 changes: 10 additions & 0 deletions pkg/apis/pipeline/v1/pipelinerun_types.go
Copy link
Owner Author

@twoGiants twoGiants Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pr-3

Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ func (pr *PipelineRun) HasStarted() bool {
return pr.Status.StartTime != nil && !pr.Status.StartTime.IsZero()
}

// IsSuccessful returns true if the PipelineRun's status indicates that it has succeeded.
func (pr *PipelineRun) IsSuccessful() bool {
return pr != nil && pr.Status.GetCondition(apis.ConditionSucceeded).IsTrue()
}

// IsFailure returns true if the PipelineRun's status indicates that it has failed.
func (pr *PipelineRun) IsFailure() bool {
return pr != nil && pr.Status.GetCondition(apis.ConditionSucceeded).IsFalse()
}

// IsCancelled returns true if the PipelineRun's spec status is set to Cancelled state
func (pr *PipelineRun) IsCancelled() bool {
return pr.Spec.Status == PipelineRunSpecStatusCancelled
Expand Down
80 changes: 80 additions & 0 deletions pkg/apis/pipeline/v1/pipelinerun_types_test.go
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pr-3

Original file line number Diff line number Diff line change
Expand Up @@ -781,3 +781,83 @@ func TestPipelineRunMarkFailedCondition(t *testing.T) {
})
}
}

func TestPipelineRunIsSuccessful(t *testing.T) {
tcs := []struct {
name string
pipelineRun *v1.PipelineRun
want bool
}{{
name: "nil pipelinerun",
want: false,
}, {
name: "still running",
pipelineRun: &v1.PipelineRun{Status: v1.PipelineRunStatus{Status: duckv1.Status{Conditions: []apis.Condition{{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionUnknown,
}}}}},
want: false,
}, {
name: "succeeded",
pipelineRun: &v1.PipelineRun{Status: v1.PipelineRunStatus{Status: duckv1.Status{Conditions: []apis.Condition{{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionTrue,
}}}}},
want: true,
}, {
name: "failed",
pipelineRun: &v1.PipelineRun{Status: v1.PipelineRunStatus{Status: duckv1.Status{Conditions: []apis.Condition{{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
}}}}},
want: false,
}}
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
got := tc.pipelineRun.IsSuccessful()
if tc.want != got {
t.Errorf("wanted IsSuccessful to be %t but was %t", tc.want, got)
}
})
}
}

func TestPipelineRunIsFailure(t *testing.T) {
tcs := []struct {
name string
pipelineRun *v1.PipelineRun
want bool
}{{
name: "nil pipelinerun",
want: false,
}, {
name: "still running",
pipelineRun: &v1.PipelineRun{Status: v1.PipelineRunStatus{Status: duckv1.Status{Conditions: []apis.Condition{{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionUnknown,
}}}}},
want: false,
}, {
name: "succeeded",
pipelineRun: &v1.PipelineRun{Status: v1.PipelineRunStatus{Status: duckv1.Status{Conditions: []apis.Condition{{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionTrue,
}}}}},
want: false,
}, {
name: "failed",
pipelineRun: &v1.PipelineRun{Status: v1.PipelineRunStatus{Status: duckv1.Status{Conditions: []apis.Condition{{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
}}}}},
want: true,
}}
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
got := tc.pipelineRun.IsFailure()
if tc.want != got {
t.Errorf("wanted IsFailure to be %t but was %t", tc.want, got)
}
})
}
}
1 change: 0 additions & 1 deletion pkg/pod/pod_test.go
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pr-1

Original file line number Diff line number Diff line change
Expand Up @@ -2622,7 +2622,6 @@ _EOF_
} else {
trAnnotations = c.trAnnotation
trAnnotations[ReleaseAnnotation] = fakeVersion

}
testTaskRunName := taskRunName
if c.trName != "" {
Expand Down
7 changes: 7 additions & 0 deletions pkg/reconciler/pipelinerun/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ func NewController(opts *pipeline.Options, clock clock.PassiveClock) func(contex
logging.FromContext(ctx).Panicf("Couldn't register PipelineRun informer event handler: %w", err)
}

if _, err := pipelineRunInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{
FilterFunc: controller.FilterController(&v1.PipelineRun{}),
Handler: controller.HandleAll(impl.EnqueueControllerOf),
}); err != nil {
logging.FromContext(ctx).Panicf("Couldn't register PipelineRun informer event handler: %w", err)
}

if _, err := taskRunInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{
FilterFunc: controller.FilterController(&v1.PipelineRun{}),
Handler: controller.HandleAll(impl.EnqueueControllerOf),
Expand Down
Loading
Loading