diff --git a/osbs/tekton.py b/osbs/tekton.py index aca44e2a..ec14254a 100644 --- a/osbs/tekton.py +++ b/osbs/tekton.py @@ -549,6 +549,8 @@ def get_error_message(self): for plugin, error in plugin_errors.items(): err_message += f"Error in plugin {plugin}: {error};\n" + pipeline_error = data['status']['conditions'][0].get('message') + for _, stats in sorted_tasks: task_name = stats['pipelineTaskName'] if stats['status']['conditions'][0]['reason'] == 'Succeeded': @@ -573,7 +575,10 @@ def get_error_message(self): continue if not err_message: - err_message = "pipeline run failed;" + if pipeline_error: + err_message = f"{pipeline_error};" + else: + err_message = "pipeline run failed;" return err_message diff --git a/tests/test_api.py b/tests/test_api.py index d52dd56c..76f40a9b 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -987,7 +987,8 @@ def test_get_build_error_message(self, osbs_binary): 'value': metadata}]}, 'pipelineTaskName': 'binary-container-exit'}} - resp = {'metadata': {'name': 'run_name'}, 'status': {'taskRuns': taskruns}} + resp = {'metadata': {'name': 'run_name'}, + 'status': {'taskRuns': taskruns, 'conditions': [{'message': 'error'}]}} flexmock(PipelineRun).should_receive('get_info').and_return(resp) diff --git a/tests/test_tekton.py b/tests/test_tekton.py index 3885a6ea..ea280760 100644 --- a/tests/test_tekton.py +++ b/tests/test_tekton.py @@ -603,12 +603,12 @@ def test_get_info(self, pipeline_run, get_json): ({}, 'pipeline run removed;'), # no taskRuns in status and no plugins-metadata - ({'status': {'conditions': [{'reason': 'reason1', 'message': 'message1'}]}, + ({'status': {'conditions': [{'reason': 'reason1', 'message': 'pipeline err message1'}]}, 'metadata': {}}, - "pipeline run failed;"), + "pipeline err message1;"), # taskRuns in status, without steps - ({'status': {'conditions': [{'reason': 'reason1', 'message': 'message1'}], + ({'status': {'conditions': [{'reason': 'reason1', 'message': 'pipeline err message1'}], 'taskRuns': { 'task1': { 'pipelineTaskName': 'binary-build-task1', @@ -618,10 +618,10 @@ def test_get_info(self, pipeline_run, get_json): } }}, 'metadata': {}}, - "pipeline run failed;"), + "pipeline err message1;"), # taskRuns in status, with steps and failed without terminated key - ({'status': {'conditions': [{'reason': 'reason1', 'message': 'message1'}], + ({'status': {'conditions': [{'reason': 'reason1'}], 'taskRuns': { 'task1': { 'pipelineTaskName': 'binary-build-task1',