Skip to content

Commit f58bc48

Browse files
committed
Add Slack notifications to CI
Closes gh-297
1 parent c4ff831 commit f58bc48

File tree

1 file changed

+44
-8
lines changed

1 file changed

+44
-8
lines changed

ci/pipeline.yml

+44-8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ anchors:
2424
docker-hub-task-params: &docker-hub-task-params
2525
DOCKER_HUB_USERNAME: ((docker-hub-username))
2626
DOCKER_HUB_PASSWORD: ((docker-hub-password))
27+
slack-fail-params: &slack-fail-params
28+
text: >
29+
:concourse-failed: <!here> <https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}|${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} failed!>
30+
silent: true
31+
icon_emoji: ":concourse:"
32+
username: concourse-ci
33+
slack-success-params: &slack-success-params
34+
text: >
35+
:concourse-succeeded: <https://ci.spring.io/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}|${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} was successful!>
36+
silent: true
37+
icon_emoji: ":concourse:"
38+
username: concourse-ci
2739
resource_types:
2840
- name: artifactory-resource
2941
type: registry-image
@@ -34,6 +46,11 @@ resource_types:
3446
type: registry-image
3547
source:
3648
repository: teliaoss/github-pr-resource
49+
- name: slack-notification
50+
type: registry-image
51+
source:
52+
repository: cfcommunity/slack-notification-resource
53+
tag: latest
3754
resources:
3855
- name: git-repo
3956
type: git
@@ -88,6 +105,11 @@ resources:
88105
username: ((artifactory-username))
89106
password: ((artifactory-password))
90107
build_name: ((build-name))
108+
- name: slack-alert
109+
type: slack-notification
110+
icon: slack
111+
source:
112+
url: ((slack-webhook-url))
91113
jobs:
92114
- name: build-ci-images
93115
plan:
@@ -111,19 +133,33 @@ jobs:
111133
- get: ci-image
112134
- get: git-repo
113135
trigger: true
114-
- task: build-project
115-
image: ci-image
116-
privileged: true
117-
timeout: ((task-timeout))
118-
file: git-repo/ci/tasks/build-project.yml
119-
params:
120-
<<: *docker-hub-task-params
121-
BRANCH: ((branch))
136+
- do:
137+
- task: build-project
138+
image: ci-image
139+
privileged: true
140+
timeout: ((task-timeout))
141+
file: git-repo/ci/tasks/build-project.yml
142+
params:
143+
<<: *docker-hub-task-params
144+
BRANCH: ((branch))
145+
on_failure:
146+
do:
147+
- put: slack-alert
148+
params:
149+
<<: *slack-fail-params
122150
- put: artifactory-repo
123151
params:
124152
<<: *artifactory-repo-put-params
125153
get_params:
126154
threads: 8
155+
on_failure:
156+
do:
157+
- put: slack-alert
158+
params:
159+
<<: *slack-fail-params
160+
- put: slack-alert
161+
params:
162+
<<: *slack-success-params
127163
- name: build-pull-requests
128164
serial: true
129165
public: true

0 commit comments

Comments
 (0)