Skip to content

Commit 0e0a383

Browse files
committed
debug: test tekton pipeline
Signed-off-by: Cagri Yonca <cagri@ibm.com>
1 parent 4180a9f commit 0e0a383

4 files changed

Lines changed: 36 additions & 11 deletions

File tree

.tekton/.currency/currency-pipelinerun.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
apiVersion: tekton.dev/v1beta1
1+
apiVersion: tekton.dev/v1
22
kind: PipelineRun
33
metadata:
44
name: python-currency-pipelinerun
55
spec:
6+
taskRunTemplate:
7+
serviceAccountName: currency-serviceaccount
68
params:
79
- name: revision
8-
value: "main"
10+
value: "cicd/security"
911
pipelineRef:
1012
name: python-currency-pipeline
11-
serviceAccountName: currency-serviceaccount
1213
workspaces:
1314
- name: currency-pvc
1415
volumeClaimTemplate:

.tekton/.currency/currency-scheduled-eventlistener.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ metadata:
1515
name: python-currency-trigger-template
1616
spec:
1717
resourcetemplates:
18-
- apiVersion: tekton.dev/v1beta1
18+
- apiVersion: tekton.dev/v1
1919
kind: PipelineRun
2020
metadata:
2121
generateName: python-currency-
2222
spec:
23+
taskRunTemplate:
24+
serviceAccountName: currency-serviceaccount
2325
pipelineRef:
2426
name: python-currency-pipeline
25-
serviceAccountName: currency-serviceaccount
2627
params:
2728
- name: revision
28-
value: "main"
29+
value: "cicd/security"
2930
workspaces:
3031
- name: currency-pvc
3132
volumeClaimTemplate:

.tekton/.currency/scripts/generate_report.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,25 @@ def get_taskruns(namespace, task_name):
168168
# access the custom resource from tekton
169169
tektonV1 = client.CustomObjectsApi(api_client)
170170
try:
171+
# Try scheduled pipeline first
171172
taskruns = tektonV1.list_namespaced_custom_object(
172173
group,
173174
version,
174175
namespace,
175176
plural,
176177
label_selector=f"{group}/task={task_name}, triggers.tekton.dev/trigger=python-tracer-scheduled-pipeline-triggger",
177178
)["items"]
179+
180+
# If no scheduled taskruns found, get all taskruns for this task
181+
if not taskruns:
182+
print(f"No scheduled taskruns found for {task_name}, searching all taskruns...")
183+
taskruns = tektonV1.list_namespaced_custom_object(
184+
group,
185+
version,
186+
namespace,
187+
plural,
188+
label_selector=f"{group}/task={task_name}",
189+
)["items"]
178190
finally:
179191
api_client.close()
180192

@@ -191,11 +203,22 @@ def process_taskrun_logs(
191203
):
192204
"""Process taskrun logs"""
193205
for tr in taskruns:
194-
pod_name = tr["status"]["podName"]
206+
pod_name = tr["status"].get("podName")
195207
taskrun_name = tr["metadata"]["name"]
196-
logs = core_v1_client.read_namespaced_pod_log(
197-
pod_name, namespace, container="step-unittest"
198-
)
208+
209+
if not pod_name:
210+
print(f"Warning: No podName found for taskrun {taskrun_name}, skipping...")
211+
continue
212+
213+
print(f"Attempting to read logs from pod: {pod_name}")
214+
215+
try:
216+
logs = core_v1_client.read_namespaced_pod_log(
217+
pod_name, namespace, container="step-unittest"
218+
)
219+
except Exception as e:
220+
print(f"Error reading logs from pod {pod_name}: {e}")
221+
continue
199222
if "Successfully installed" in logs:
200223
print(
201224
f"Retrieving container logs from the successful taskrun pod {pod_name} of taskrun {taskrun_name}.."

.tekton/pipelinerun.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: python-tracer-ci-pipeline-run
55
spec:
66
taskRunTemplate:
7-
serviceAccountName: currency-serviceaccount
7+
serviceAccountName: default
88
params:
99
- name: revision
1010
value: "tekton"

0 commit comments

Comments
 (0)