also looking at this
fix(setup): make custom plugins able to run at all
#1416
5 files
+401
-31
renamed throughout · 11 hidden lines
| @@ -438,9 +438,9 @@ export JIRA_PROJECT_KEY="BUDDY" # Optional, defaults to BUDDY renamed throughout | ||
| 438 | 438 | Create custom integrations by defining plugins in `.buddy/plugins/`: |
| 439 | 439 | |
| 440 | 440 | ```jsonc |
| 441 | // .buddy/plugins/custom-integration.json | |
| 441 | // .buddy/plugins/custom-notify.json | |
| 442 | 442 | { |
| 443 | "name": "custom-integration", | |
| 443 | "name": "custom-notify", | |
| 444 | 444 | "version": "1.0.0", |
| 445 | 445 | "enabled": true, |
| 446 | 446 | "triggers": [ |
| @@ -449,19 +449,25 @@ Create custom integrations by defining plugins in `.buddy/plugins/`: | ||
| 449 | 449 | ], |
| 450 | 450 | "hooks": [ |
| 451 | 451 | { |
| 452 | "name": "custom-notification", | |
| 452 | "name": "notify", | |
| 453 | 453 | "priority": 10, |
| 454 | "async": true, | |
| 455 | "handler": "// Custom JavaScript function" | |
| 454 | "action": { | |
| 455 | "type": "webhook", | |
| 456 | "url": "https://your-webhook.com/notify", | |
| 457 | "body": { "channel": "#builds" } | |
| 458 | } | |
| 456 | 459 | } |
| 457 | ], | |
| 458 | "configuration": { | |
| 459 | "webhook_url": "https://your-custom-webhook.com/notify", | |
| 460 | "api_key": "your-api-key" | |
| 461 | } | |
| 460 | ] | |
| 462 | 461 | } |
| 463 | 462 | ``` |
| 464 | 463 | |
| 464 | A hook declares an `action` rather than a function. JSON has no way to carry | |
| 465 | one, and reading a string out of a config file to run as code would turn any | |
| 466 | `.buddy/plugins/*.json` in a repository into arbitrary code execution on | |
| 467 | whoever runs `buddy setup`. The payload names the event and the repository | |
| 468 | and nothing else, plus whatever `body` adds — setup holds a token by the time | |
| 469 | hooks run, and the plugin file chooses the URL. | |
| 470 | ||
| 465 | 471 | ### Plugin Events |
| 466 | 472 | |
| 467 | 473 | | Event | Description | Context | |