|
| 1 | +# Rocket.Chat |
| 2 | + |
| 3 | +## Parameters |
| 4 | + |
| 5 | +The Rocket.Chat notification service configuration includes following settings: |
| 6 | + |
| 7 | +* `email` - the Rocker.Chat user's email |
| 8 | +* `password` - the Rocker.Chat user's password |
| 9 | +* `alias` - optional alias that should be used to post message |
| 10 | +* `icon` - optional message icon |
| 11 | +* `avatar` - optional message avatar |
| 12 | +* `serverUrl` - optional Rocket.Chat server url |
| 13 | + |
| 14 | +## Configuration |
| 15 | + |
| 16 | +1. Login to your RocketChat instance |
| 17 | +2. Go to user management |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +3. Add new user with `bot` role. Also note that `Require password change` checkbox mus be not checked |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +4. Copy username and password that you was created for bot user |
| 26 | +5. Create a public or private channel, or a team, for this example `my_channel` |
| 27 | +6. Add your bot to this channel **otherwise it won't work** |
| 28 | +7. Store email and password in argocd_notifications-secret Secret |
| 29 | + |
| 30 | +```yaml |
| 31 | +apiVersion: v1 |
| 32 | +kind: Secret |
| 33 | +metadata: |
| 34 | + name: <secret-name> |
| 35 | +stringData: |
| 36 | + rocketchat-email: <email> |
| 37 | + rocketchat-password: <password> |
| 38 | +``` |
| 39 | +
|
| 40 | +8. Finally, use these credentials to configure the RocketChat integration in the `argocd-configmap` config map: |
| 41 | + |
| 42 | +```yaml |
| 43 | +apiVersion: v1 |
| 44 | +kind: ConfigMap |
| 45 | +metadata: |
| 46 | + name: <config-map-name> |
| 47 | +data: |
| 48 | + service.rocketchat: | |
| 49 | + email: $rocketchat-email |
| 50 | + password: $rocketchat-password |
| 51 | +``` |
| 52 | + |
| 53 | +9. Create a subscription for your Rocket.Chat integration: |
| 54 | + |
| 55 | +*Note: channel, team or user must be prefixed with # or @ elsewhere we will be interpretative destination as a room ID* |
| 56 | + |
| 57 | +```yaml |
| 58 | +apiVersion: argoproj.io/v1alpha1 |
| 59 | +kind: Application |
| 60 | +metadata: |
| 61 | + annotations: |
| 62 | + notifications.argoproj.io/subscribe.on-sync-succeeded.rocketchat: #my_channel |
| 63 | +``` |
| 64 | + |
| 65 | +## Templates |
| 66 | + |
| 67 | +Notification templates can be customized with RocketChat [attachments](https://developer.rocket.chat/api/rest-api/methods/chat/postmessage#attachments-detail). |
| 68 | + |
| 69 | +*Note: Attachments structure in Rocketchat is same with Slack attachments [feature](https://api.slack.com/messaging/composing/layouts).* |
| 70 | + |
| 71 | +<!-- TODO: @sergeyshevch Need to add screenshot with RocketChat attachments --> |
| 72 | + |
| 73 | +The message attachments can be specified in `attachments` string fields under `rocketchat` field: |
| 74 | + |
| 75 | +```yaml |
| 76 | +template.app-sync-status: | |
| 77 | + message: | |
| 78 | + Application {{.app.metadata.name}} sync is {{.app.status.sync.status}}. |
| 79 | + Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}. |
| 80 | + rocketchat: |
| 81 | + attachments: | |
| 82 | + [{ |
| 83 | + "title": "{{.app.metadata.name}}", |
| 84 | + "title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}", |
| 85 | + "color": "#18be52", |
| 86 | + "fields": [{ |
| 87 | + "title": "Sync Status", |
| 88 | + "value": "{{.app.status.sync.status}}", |
| 89 | + "short": true |
| 90 | + }, { |
| 91 | + "title": "Repository", |
| 92 | + "value": "{{.app.spec.source.repoURL}}", |
| 93 | + "short": true |
| 94 | + }] |
| 95 | + }] |
| 96 | +``` |
0 commit comments