1
- How to setup build status webhooks
2
- ==================================
1
+ Setting up outgoing webhooks
2
+ ============================
3
3
4
- In this guide,
5
- you can learn how to setup build notifications via webhooks.
6
-
7
- When a documentation build is *triggered *, *successful * or *failed *,
8
- Read the Docs can notify external APIs using :term: `webhooks <webhook> `.
9
- In that way,
10
- you can receive build notifications in your own monitoring channels and be alerted you when your builds fail so you can take immediate action.
4
+ When a project build is *triggered *, *successful * or *failed *,
5
+ Read the Docs can notify external APIs using outgoing :term: `webhooks <webhook> `.
6
+ These webhooks contain information about the build and build status
7
+ and can allow an external service to use this information for alerting,
8
+ monitoring, and many other custom configurations.
11
9
12
10
.. seealso ::
13
11
@@ -17,25 +15,30 @@ you can receive build notifications in your own monitoring channels and be alert
17
15
:doc: `/pull-requests `
18
16
Configure automated feedback and documentation site previews for your pull requests.
19
17
18
+ .. note ::
20
19
21
- Build status webhooks
22
- ---------------------
20
+ :doc: `Builds for pull requests </pull-requests >` do not trigger outgoing :term: `webhooks <webhook> `.
23
21
24
- Take these steps to enable build notifications using a webhook:
22
+ Creating a new webhook
23
+ ----------------------
25
24
26
- * Go to :menuselection: `Admin --> Webhooks ` in your project.
27
- * Fill in the **URL ** field and select what events will trigger the webhook
28
- * Modify the payload or leave the default (see below)
29
- * Click on :guilabel: `Save `
25
+ To create a new outgoing webhook for your project:
30
26
31
- .. figure :: /_static/images/webhooks-events.png
32
- :align: center
33
- :alt: URL and events for a webhook
27
+ * Go to :menuselection: `Settings --> Outgoing webhooks ` in your project.
28
+ * Click :guilabel: `Add webhook `.
29
+ * Fill in the :guilabel: `URL ` field with the target URL for your endpoint.
30
+ * Select the which events will trigger the webhook.
31
+ * Modify the :guilabel: `JSON payload ` field or leave the default (see below for more).
32
+ * Click on :guilabel: `Add webhook `
33
+
34
+ .. figure :: /img/screenshots/community-project-webhook-create.png
35
+ :align: center
36
+ :alt: Form for creating a new webhook
34
37
35
- URL and events for a webhook
38
+ Form for creating a new webhook
36
39
37
- Every time one of the checked events triggers ,
38
- Read the Docs will send a POST request to your webhook URL.
40
+ Every time one of the selected events trigger ,
41
+ Read the Docs will send a POST request to your webhook target URL.
39
42
The default payload will look like this:
40
43
41
44
.. code-block :: json
@@ -52,34 +55,70 @@ The default payload will look like this:
52
55
"docs_url" : " https://docs.readthedocs.io/en/latest/"
53
56
}
54
57
55
- When a webhook is sent, a new entry will be added to the
56
- "Recent Activity" table. By clicking on each individual entry,
57
- you will see the server response, the webhook request, and the payload.
58
+ When a webhook is sent, a new entry will be added to the :guilabel: `Recent activity ` list.
59
+ You can click on each entry to see the webhook request, response, and the request payload.
58
60
59
- .. figure :: /_static/images/webhooks -activity.png
61
+ .. figure :: /img/screenshots/community-project-webhook -activity.png
60
62
:align: center
61
- :alt: Activity of a webhook
63
+ :alt: Recent activity of a webhook
62
64
63
- Activity of a webhook
65
+ Recent activity of a webhook
64
66
65
- .. note ::
67
+ Custom payloads
68
+ ---------------
66
69
67
- We don't trigger :term: `webhooks <webhook> ` on :doc: `builds from pull requests </pull-requests >`.
70
+ You can customize the payload of the webhook to fit the expected structure of your target endpoint.
71
+ The payload structure must be valid JSON but can contain any of our
72
+ `payload variable substitutions <Payload variable reference >`_.
68
73
74
+ Variable substitutions
75
+ ~~~~~~~~~~~~~~~~~~~~~~
69
76
70
- Custom payload examples
71
- ~~~~~~~~~~~~~~~~~~~~~~~
77
+ The following variable strings can be used in a custom payload to substitute information
78
+ about the build and project in the webhook body.
72
79
73
- You can customize the payload of the webhook to suit your needs,
74
- as long as it is valid JSON. Below you have a couple of examples,
75
- and in the following section you will find all the available variables.
80
+ ``{{ event }} ``
81
+ Event that triggered the webhook, one of ``build:triggered ``, ``build:failed ``, or ``build:passed ``.
76
82
77
- .. figure :: /_static/images/webhooks-payload.png
78
- :width: 80%
79
- :align: center
80
- :alt: Custom payload
83
+ ``{{ build.id }} ``
84
+ Build ID.
85
+
86
+ ``{{ build.commit }} ``
87
+ Commit corresponding to the build, if present (otherwise ``"" ``).
88
+
89
+ ``{{ build.url }} ``
90
+ URL of the build, for example ``https://app.readthedocs.org/projects/docs/builds/15173336/ ``.
91
+
92
+ ``{{ build.docs_url }} ``
93
+ URL of the documentation corresponding to the build,
94
+ for example ``https://docs.readthedocs.io/en/latest/ ``.
95
+
96
+ ``{{ build.start_date }} ``
97
+ Start date of the build (UTC, ISO format), for example ``2021-11-03T16:23:14 ``.
98
+
99
+ ``{{ organization.name }} ``
100
+ Organization name (Commercial only).
101
+
102
+ ``{{ organization.slug }} ``
103
+ Organization slug (Commercial only).
104
+
105
+ ``{{ project.slug }} ``
106
+ Project slug.
107
+
108
+ ``{{ project.name }} ``
109
+ Project name.
110
+
111
+ ``{{ project.url }} ``
112
+ URL of the project :term: `dashboard `.
113
+
114
+ ``{{ version.slug }} ``
115
+ Version slug.
116
+
117
+ ``{{ version.name }} ``
118
+ Version name.
81
119
82
- Custom payload
120
+ Examples
121
+ ~~~~~~~~
83
122
84
123
.. tabs ::
85
124
@@ -121,7 +160,8 @@ and in the following section you will find all the available variables.
121
160
]
122
161
}
123
162
124
- More information on `the Slack Incoming Webhooks documentation <https://api.slack.com/messaging/webhooks >`_.
163
+ .. seealso ::
164
+ `Slack Incoming Webhooks documentation <https://api.slack.com/messaging/webhooks >`_
125
165
126
166
.. tab :: Discord
127
167
@@ -155,59 +195,17 @@ and in the following section you will find all the available variables.
155
195
]
156
196
}
157
197
158
- More information on `the Discord webhooks documentation <https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks >`_.
159
-
160
- Variable substitutions reference
161
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
162
-
163
- ``{{ event }} ``
164
- Event that triggered the webhook, one of ``build:triggered ``, ``build:failed ``, or ``build:passed ``.
165
-
166
- ``{{ build.id }} ``
167
- Build ID.
168
-
169
- ``{{ build.commit }} ``
170
- Commit corresponding to the build, if present (otherwise ``"" ``).
171
-
172
- ``{{ build.url }} ``
173
- URL of the build, for example ``https://app.readthedocs.org/projects/docs/builds/15173336/ ``.
174
-
175
- ``{{ build.docs_url }} ``
176
- URL of the documentation corresponding to the build,
177
- for example ``https://docs.readthedocs.io/en/latest/ ``.
178
-
179
- ``{{ build.start_date }} ``
180
- Start date of the build (UTC, ISO format), for example ``2021-11-03T16:23:14 ``.
181
-
182
- ``{{ organization.name }} ``
183
- Organization name (Commercial only).
184
-
185
- ``{{ organization.slug }} ``
186
- Organization slug (Commercial only).
187
-
188
- ``{{ project.slug }} ``
189
- Project slug.
190
-
191
- ``{{ project.name }} ``
192
- Project name.
198
+ .. seealso ::
199
+ `Discord webhooks documentation <https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks >`_
193
200
194
- ``{{ project.url }} ``
195
- URL of the project :term: `dashboard `.
196
-
197
- ``{{ version.slug }} ``
198
- Version slug.
199
-
200
- ``{{ version.name }} ``
201
- Version name.
202
-
203
- Validating the payload
204
- ----------------------
201
+ Verifying the payload
202
+ ---------------------
205
203
206
204
After you add a new webhook, Read the Docs will generate a secret key for it
207
- and uses it to generate a hash signature (HMAC-SHA256) for each payload
208
- that is included in the ``X-Hub-Signature `` header of the request.
205
+ and use the key to generate a hash signature (HMAC-SHA256) for each payload.
206
+ This signature is included in the ``X-Hub-Signature `` header of each request.
209
207
210
- .. figure :: /_static/images/webhooks -secret.png
208
+ .. figure :: /img/screenshots/community-project-webhook -secret.png
211
209
:width: 80%
212
210
:align: center
213
211
:alt: Webhook secret
@@ -263,7 +261,7 @@ send a payload with the following structure:
263
261
}
264
262
265
263
To migrate to the new webhooks and keep a similar structure,
266
- you can use this payload:
264
+ you can use this as the webhook custom payload:
267
265
268
266
.. code-block :: json
269
267
@@ -281,17 +279,18 @@ you can use this payload:
281
279
Troubleshooting webhooks and payload discovery
282
280
----------------------------------------------
283
281
284
- You can use public tools to discover, inspect and test webhook
285
- integration. These tools act as catch-all endpoints for HTTP requests
282
+ You can use public tools to discover, inspect, and test outgoing webhooks.
283
+ These tools act as catch-all endpoints for HTTP requests
286
284
and respond with a 200 OK HTTP status code. You can use these payloads
287
285
to develop your webhook services. You should exercise caution when using
288
286
these tools as you might be sending sensitive data to external tools.
289
287
290
288
These public tools include:
291
289
292
- - `Beeceptor <https://beeceptor.com/webhook-integration/ >`__ to create
293
- a temporary HTTPS endpoint and inspect incoming payloads. It lets you
294
- respond custom response code or messages from named HTTP mock server.
295
- - `Webhook Tester <https://webhook-test.com/ >`__ to inspect and debug
296
- incoming payloads. It lets you inspect all incoming requests to it’s
297
- URL/bucket.
290
+ `Beeceptor <https://beeceptor.com/webhook-integration/ >`__
291
+ Create a temporary HTTPS endpoint and inspect incoming payloads. It lets you
292
+ respond custom response code or messages from named HTTP mock server.
293
+
294
+ `Webhook Tester <https://webhook-test.com/ >`__
295
+ Inspect and debug incoming payloads. It lets you inspect all incoming
296
+ requests to it’s URL/bucket.
0 commit comments