@@ -202,44 +202,37 @@ def process_taskrun_logs(
202202
203203def get_tekton_ci_output ():
204204 """Get the latest successful scheduled tekton pipeline output"""
205- # # To run locally
206- # config.load_kube_config()
207-
208- ## To run inside the tekton kubernetes cluster
209- config .load_incluster_config ()
205+ try :
206+ config .load_incluster_config ()
207+ print ("Using in-cluster Kubernetes configuration..." )
208+ except config .config_exception .ConfigException :
209+ # Fall back to local config if running locally and not inside cluster
210+ config .load_kube_config ()
211+ print ("Using local Kubernetes configuration..." )
210212
211213 namespace = "default"
212214 core_v1_client = client .CoreV1Api ()
213215
214216 taskrun_filter = lambda tr : tr ["status" ]["conditions" ][0 ]["type" ] == "Succeeded" # noqa: E731
215217
216- task_name = "python-tracer-unittest-gevent-starlette-task"
217- starlette_taskruns = get_taskruns (namespace , task_name , taskrun_filter )
218-
219- tekton_ci_output = process_taskrun_logs (
220- starlette_taskruns , core_v1_client , namespace , task_name , ""
221- )
222-
223- task_name = "python-tracer-unittest-kafka-task"
224- kafka_taskruns = get_taskruns (namespace , task_name , taskrun_filter )
225-
226- tekton_ci_output = process_taskrun_logs (
227- kafka_taskruns , core_v1_client , namespace , task_name , tekton_ci_output
228- )
229-
230- task_name = "python-tracer-unittest-cassandra-task"
231- cassandra_taskruns = get_taskruns (namespace , task_name , taskrun_filter )
232-
233- tekton_ci_output = process_taskrun_logs (
234- cassandra_taskruns , core_v1_client , namespace , task_name , tekton_ci_output
235- )
236-
237- task_name = "python-tracer-unittest-default-task"
238- default_taskruns = get_taskruns (namespace , task_name , taskrun_filter )
239-
240- tekton_ci_output = process_taskrun_logs (
241- default_taskruns , core_v1_client , namespace , task_name , tekton_ci_output
242- )
218+ tasks = [
219+ "python-tracer-unittest-gevent-starlette-task" ,
220+ "python-tracer-unittest-kafka-task" ,
221+ "python-tracer-unittest-cassandra-task" ,
222+ "python-tracer-unittest-default-task"
223+ ]
224+
225+ tekton_ci_output = ""
226+
227+ for task_name in tasks :
228+ try :
229+ taskruns = get_taskruns (namespace , task_name , taskrun_filter )
230+
231+ tekton_ci_output = process_taskrun_logs (
232+ taskruns , core_v1_client , namespace , task_name , tekton_ci_output
233+ )
234+ except Exception as exc :
235+ print (f"Error processing task { task_name } : { str (exc )} " )
243236
244237 return tekton_ci_output
245238
0 commit comments