also looking at this
fix(setup): make custom plugins able to run at all
#1416
5 files
+401
-31
| @@ -1187,30 +1187,36 @@ export JIRA_PROJECT_KEY="BUDDY" # Optional, defaults to BUDDY | ||
| 1187 | 1187 | Create custom integrations by defining plugins in `.buddy/plugins/`: |
| 1188 | 1188 | |
| 1189 | 1189 | ```jsonc |
| 1190 | // .buddy/plugins/custom-integration.json | |
| 1190 | // .buddy/plugins/custom-notify.json | |
| 1191 | 1191 | { |
| 1192 | "name": "custom-integration", | |
| 1192 | "name": "custom-notify", | |
| 1193 | 1193 | "version": "1.0.0", |
| 1194 | 1194 | "enabled": true, |
| 1195 | 1195 | "triggers": [ |
| 1196 | { "event": "setup*complete" }, | |
| 1197 | { "event": "validation*error" } | |
| 1196 | { "event": "setup_complete" }, | |
| 1197 | { "event": "validation_error" } | |
| 1198 | 1198 | ], |
| 1199 | 1199 | "hooks": [ |
| 1200 | 1200 | { |
| 1201 | "name": "custom-notification", | |
| 1201 | "name": "notify", | |
| 1202 | 1202 | "priority": 10, |
| 1203 | "async": true, | |
| 1204 | "handler": "// Custom JavaScript function" | |
| 1203 | "action": { | |
| 1204 | "type": "webhook", | |
| 1205 | "url": "https://your-webhook.com/notify", | |
| 1206 | "body": { "channel": "#builds" } | |
| 1207 | } | |
| 1205 | 1208 | } |
| 1206 | ], | |
| 1207 | "configuration": { | |
| 1208 | "webhook*url": "https://your-custom-webhook.com/notify", | |
| 1209 | "api*key": "your-api-key" | |
| 1210 | } | |
| 1209 | ] | |
| 1211 | 1210 | } |
| 1212 | 1211 | ``` |
| 1213 | 1212 | |
| 1213 | A hook declares an `action` rather than a function. JSON has no way to carry | |
| 1214 | one, and reading a string out of a config file to run as code would turn any | |
| 1215 | `.buddy/plugins/*.json` in a repository into arbitrary code execution on | |
| 1216 | whoever runs `buddy setup`. The payload names the event and the repository | |
| 1217 | and nothing else, plus whatever `body` adds — setup holds a token by the time | |
| 1218 | hooks run, and the plugin file chooses the URL. | |
| 1219 | ||
| 1214 | 1220 | ### Plugin Events |
| 1215 | 1221 | |
| 1216 | 1222 | | Event | Description | Context | |