# Generate notifications, using Cycloid events as example
Most of our customers ask to send notifications for pipeline status on Slack, Github, etc.
The best approach to sending notifications is to use resources. Pipelines are flexible, and resources can add many functionalities. You can integrate any notification type by using existing resource (opens new window) or by creating your own (opens new window).
Let's use Cycloid events as example of notification.
Before using events, we advise you to
- Create a Cycloid API key with
all actions
for testing purposes. - Put the API key inside a Cycloid credential to be able to use it easily inside the pipeline.
Create a dedicated custom credential type called custom_cyclobot-api-key
containing a field key
like this:
This should produce a Vault credential with custom_cyclobot-api-key.key
as the path and key to access it.
Also, and you might already know the next step, if we want to keep our pipeline generic, we must define a new variable for the API key before using it in our pipeline:
Follow those steps to apply all changes described in this step
stack-sample/pipeline/variables.sample.yml
# Cycloid events configuration
api_key: ((custom_cyclobot-api-key.key))
api_url: https://http-api.cycloid.io
2
3
At this point, we are ready to configure a new cycloid-events
resource in the pipeline and use it in our job:
stack-sample/pipeline/pipeline.yml
resource_types:
...
- name: cycloid-events
type: docker-image
source:
repository: cycloid/cycloid-events-resource
resources:
...
- name: cycloid-events
type: cycloid-events
source:
api_key: ((api_key))
api_url: ((api_url))
icon: fa-code-branch
organization: ((customer))
severity: info
type: Custom
tags:
- key: project
value: ((project))
- key: env
value: ((env))
- key: customer
value: ((customer))
jobs:
...
- name: functional-tests
plan:
- do:
...
on_failure:
do:
- put: cycloid-events
params:
severity: crit
message: Oops
title: The deployment of ((project)) owl have failed on ((env)) environment
on_success:
do:
- put: cycloid-events
params:
message: Congrats !
title: Successful deployment of ((project)) owl on ((env)) environment
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
First, define a new type of resource, cycloid-events
, and configure it in the resources
section. Finally, add a pipeline step hook (opens new window) for success and failure, which call the cycloid-events
resource.
Add and commit those changes in Git:
git add .
git commit -m "Step 7"
git push origin stacks
2
3
Get back to Cycloid's dashboard, and click on the Refresh pipeline
button .
After running the pipeline, a new Cycloid event should be visible on the event view:
# Key points to remember
- You can integrate any notification type by using existing resource (opens new window) or by creating your own (opens new window)
- You can use Cycloid events as example of notification
- You can add a pipeline step hook (opens new window) for success and failure