Skip to content

Commit 64e658e

Browse files
committed
feat: update get-failed-info step SD-1405
1 parent aae8598 commit 64e658e

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 2025-10-16
4+
5+
[dev]
6+
7+
- [associated PR](https://github.com/saritasa-nest/saritasa-devops-helm-charts/pull/178)
8+
- Update slack-notification `get-failed-info` step
9+
310
## 2025-10-06
411

512
[dev]

charts/tekton-pipelines/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type: application
66
# This is the chart version. This version number should be incremented each time you make changes
77
# to the chart and its templates, including the app version.
88
# Versions are expected to follow Semantic Versioning (https://semver.org/)
9-
version: 2.2.12
9+
version: 2.2.14-dev.1
1010

1111
maintainers:
1212
- url: https://www.saritasa.com/

charts/tekton-pipelines/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ saritasa-tekton-pipelines
3131

3232
## `chart.version`
3333

34-
![Version: 2.2.12](https://img.shields.io/badge/Version-2.2.12-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
34+
![Version: 2.2.14-dev.1](https://img.shields.io/badge/Version-2.2.14-dev.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
3535

3636
## Maintainers
3737

charts/tekton-pipelines/templates/common/tasks/slack-notification.yaml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,30 @@ spec:
4949
script: |
5050
#!/bin/sh
5151
52-
pipelinerun_name=$(awk -F= '/tekton.dev\/pipelineRun/ {gsub(/"/, "", $2);print $2}' /etc/podinfo/labels)
52+
pipelinerun_name=$(awk -F= '$1 == "tekton.dev/pipelineRun" {gsub(/"/, "", $2); print $2}' /etc/podinfo/labels)
53+
54+
# Get names of taskRuns from the pipelineRun
55+
taskruns=$(kubectl -n ci get pipelinerun $pipelinerun_name -o json | jq -r '.status.childReferences[]?.name')
5356
54-
# get failed info from pipelinerun name
55-
kubectl -n ci get pipelinerun $pipelinerun_name -o json |
56-
jq '[.status.taskRuns | to_entries[] | select ( .value.status.conditions[0].reason == "Failed") |
57-
{ task: .value.pipelineTaskName, pod: .value.status.podName, steps: .value.status.steps[] } |
58-
select (.steps.terminated.reason == "Error")][0] | { task: .task, pod: .pod, step: .steps.name }' \
59-
> $(results.failed_info.path)
57+
# Get names of failed task and step from the taskRun
58+
for taskrun_name in $taskruns; do
59+
kubectl -n ci get taskrun $taskrun_name -o json |
60+
jq -r 'select(.status.conditions[0].reason == "Failed") |
61+
{ pod: .status.podName, task: .metadata.labels["tekton.dev/pipelineTask"], step: (.status.steps[]? | select(.terminated.reason == "Error") | .name)}' \
62+
>> $(results.failed_info.path)
63+
done
6064
6165
failed_pod_name=$(cat $(results.failed_info.path) | jq '.pod' -r)
6266
failed_task=$(cat $(results.failed_info.path) | jq '.task' -r)
6367
failed_step=$(cat $(results.failed_info.path) | jq '.step' -r)
6468
65-
if [ "$failed_pod_name" != "null" ] && [ "$failed_step" != "null" ]; then
66-
kubectl -n ci logs $failed_pod_name -c step-$failed_step | tail -c 1982 > $(results.logs.path)
69+
# Fetch logs and save info about the failed task
70+
if [ -n "$failed_pod_name" ] && [ -n "$failed_step" ]; then
6771
echo $failed_task > $(results.failed_task.path)
6872
echo $failed_step > $(results.failed_step.path)
73+
74+
echo "Fetching logs from: $logs_url"
75+
curl -sk "https://tekton-logs-server.ci.svc.cluster.local/logs/ci/${failed_pod_name}/step-${failed_step}" | tail -c 1982 > "$(results.logs.path)"
6976
fi
7077
7178
- name: notification

0 commit comments

Comments
 (0)