56
56
- name : kind
57
57
value : task
58
58
resolver : bundles
59
+ - name : send-slack-notification
60
+ params :
61
+ - name : message
62
+ value : " $(tasks.rhoai-init.results.slack-message-failure-text)"
63
+ - name : secret-name
64
+ value : rhoai-konflux-secret
65
+ - name : key-name
66
+ value : slack-webhook
67
+ taskRef :
68
+ params :
69
+ - name : name
70
+ value : slack-webhook-notification
71
+ - name : bundle
72
+ value : quay.io/konflux-ci/tekton-catalog/task-slack-webhook-notification:0.1@sha256:dc17b70633363d78414b8c06dc1660d25742935f106a6116995638e1210c2730
73
+ - name : kind
74
+ value : task
75
+ resolver : bundles
76
+ when :
77
+ - input : $(tasks.status)
78
+ operator : in
79
+ values :
80
+ - " Failed"
59
81
params :
60
82
- description : Source Repository URL
61
83
name : git-url
@@ -138,6 +160,49 @@ spec:
138
160
name : CHAINS-GIT_COMMIT
139
161
value : $(tasks.clone-repository.results.commit)
140
162
tasks :
163
+ - name : rhoai-init
164
+ params :
165
+ - name : pipelinerun-name
166
+ value : " $(context.pipelineRun.name)"
167
+ taskSpec :
168
+ results :
169
+ - description : Notification text to be posted to slack
170
+ name : slack-message-failure-text
171
+ steps :
172
+ - image : quay.io/rhoai-konflux/alpine:latest
173
+ name : rhoai-init
174
+ env :
175
+ - name : slack_message
176
+ valueFrom :
177
+ secretKeyRef :
178
+ name : rhoai-slack-message
179
+ key : slack-component-failure-notification
180
+ script : |
181
+ pipelinerun_name=$(params.pipelinerun-name)
182
+ echo "pipelinerun_name = $pipelinerun_name"
183
+
184
+ target_branch={{target_branch}}
185
+ echo "target_branch = $target_branch"
186
+
187
+ application_name=${target_branch/rhoai-/}
188
+ echo "application-name = $application_name"
189
+
190
+ application_name=rhoai-v${application_name/./-}
191
+ echo "application-name = $application_name"
192
+
193
+ component_name=${pipelinerun_name/-on-*/}
194
+ echo "component-name = $component_name"
195
+
196
+ KONFLUX_SERVER="https://console.redhat.com"
197
+ build_url="${KONFLUX_SERVER}/application-pipeline/workspaces/rhoai/applications/${application_name}/pipelineruns/${pipelinerun_name}/logs"
198
+
199
+ build_time="$(date +%Y-%m-%dT%H:%M:%S)"
200
+
201
+ slack_message=${slack_message/__BUILD__URL__/$build_url}
202
+ slack_message=${slack_message/__PIPELINERUN__NAME__/$pipelinerun_name}
203
+ slack_message=${slack_message/__BUILD__TIME__/$build_time}
204
+
205
+ echo -en "${slack_message}" > "$(results.slack-message-failure-text.path)"
141
206
- name : init
142
207
params :
143
208
- name : image-url
@@ -155,6 +220,8 @@ spec:
155
220
- name : kind
156
221
value : task
157
222
resolver : bundles
223
+ runAfter :
224
+ - rhoai-init
158
225
- name : clone-repository
159
226
params :
160
227
- name : url
0 commit comments