Skip to content

Commit a86684a

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

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

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.14-dev.1
9+
version: 2.2.14-dev.2
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.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)
34+
![Version: 2.2.14-dev.2](https://img.shields.io/badge/Version-2.2.14-dev.2-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: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,39 @@ spec:
4949
script: |
5050
#!/bin/sh
5151
52+
status="`echo $(params.status) | tr '[:upper:]' '[:lower:]'`"
53+
54+
# Exit early if deploy succeeded
55+
if [ "$status" = "succeeded" ]; then
56+
echo "Deploy succeeded, no failed tasks to analyze"
57+
exit 0
58+
fi
59+
5260
pipelinerun_name=$(awk -F= '$1 == "tekton.dev/pipelineRun" {gsub(/"/, "", $2); print $2}' /etc/podinfo/labels)
5361
5462
# Get names of taskRuns from the pipelineRun
5563
taskruns=$(kubectl -n ci get pipelinerun $pipelinerun_name -o json | jq -r '.status.childReferences[]?.name')
5664
57-
# Get names of failed task and step from the taskRun
65+
# Get names of failed pod, task and step from the taskRuns
5866
for taskrun_name in $taskruns; do
5967
kubectl -n ci get taskrun $taskrun_name -o json |
6068
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)}' \
69+
{ pod: .status.podName,
70+
task: .metadata.labels["tekton.dev/pipelineTask"],
71+
step: (.status.steps[]? | select(.terminated.reason == "Error" and (.terminationReason != "Skipped")) | .name)}' \
6272
>> $(results.failed_info.path)
6373
done
6474
6575
failed_pod_name=$(cat $(results.failed_info.path) | jq '.pod' -r)
6676
failed_task=$(cat $(results.failed_info.path) | jq '.task' -r)
6777
failed_step=$(cat $(results.failed_info.path) | jq '.step' -r)
6878
69-
# Fetch logs and save info about the failed task
7079
if [ -n "$failed_pod_name" ] && [ -n "$failed_step" ]; then
80+
# Fetch logs and save info about the failed task
81+
echo "Fetching logs for failed task: ${failed_task}, step: ${failed_step}"
82+
curl -sk "https://tekton-logs-server.ci.svc.cluster.local/logs/ci/${failed_pod_name}/step-${failed_step}" | tail -c 1982 > $(results.logs.path)
7183
echo $failed_task > $(results.failed_task.path)
7284
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)"
7685
fi
7786
7887
- name: notification

0 commit comments

Comments
 (0)