2017-12-16 07:29:19 -05:00
---
id: notifications
2018-03-05 01:13:01 -05:00
title: "Notificaciones"
2017-12-16 07:29:19 -05:00
---
2018-03-05 01:13:01 -05:00
Las notificaciones fueron introducidas con la idea de usar webhooks para Slack, pero también se puede enviar un *payload* a cualquier endpoint. Actualmente solo activo para los comandos `publish` / `create` .
2017-12-16 07:29:19 -05:00
2018-03-05 01:13:01 -05:00
## Uso
2017-12-16 07:29:19 -05:00
2018-05-24 06:08:15 -05:00
An example with a **HipChat** and **Google Hangouts Chat** hook:
2017-12-16 07:29:19 -05:00
2018-03-05 01:13:01 -05:00
#### Notificación sencilla
2017-12-16 07:29:19 -05:00
```yaml
notify:
method: POST
headers: [{'Content-Type': 'application/json'}]
endpoint: https://usagge.hipchat.com/v2/room/3729485/notification?auth_token=mySecretToken
content: '{"color":"green","message":"New package published: * {{ name }}* ","notify":true,"message_format":"text"}'
```
2018-03-05 01:13:01 -05:00
#### Múltiples notificaciones
2017-12-16 07:29:19 -05:00
```yaml
notify:
2018-05-24 06:08:15 -05:00
'example-google-chat':
method: POST
headers: [{'Content-Type': 'application/json'}]
endpoint: https://chat.googleapis.com/v1/spaces/AAAAB_TcJYs/messages?key=myKey& token=myToken
content: '{"text":"New package published: `{{ name }}{{#each versions}} v{{version}}{{/each}}` "}'
'example-hipchat':
2017-12-16 07:29:19 -05:00
method: POST
headers: [{'Content-Type': 'application/json'}]
endpoint: https://usagge.hipchat.com/v2/room/3729485/notification?auth_token=mySecretToken
content: '{"color":"green","message":"New package published: * {{ name }}* ","notify":true,"message_format":"text"}'
```
2018-03-05 01:13:01 -05:00
## Configuración
2017-12-16 07:29:19 -05:00
2018-03-05 01:13:01 -05:00
| Propiedad | Tipo | Requerido | Soporte | Por Defecto | Descripción |
| ------------------- | ------------ | --------- | ------- | ----------- | -------------------------------------------------------------------------------------------- |
| method | string | No | all | | HTTP verb |
| packagePattern | string | No | all | | Solo ejecutar esta notificación si el nombre del paquete coincide con la expresión regular |
| packagePatternFlags | string | No | all | | Any flags to be used with the regular expression |
2018-03-05 02:22:22 -05:00
| headers | array/object | Yes | all | | Si el endpoint requiere encabezados específicos, defínelos aquí como un arreglo (key:value). |
| endpoint | string | Yes | all | | define el URL para el endpoint |
2018-05-24 06:08:15 -05:00
| content | string | Yes | all | | any [handlebar ](https://handlebarsjs.com/ ) expressions |