|
| 1 | +# flyteplugins-webhooks-jira |
| 2 | + |
| 3 | +Receive Jira webhooks in Flyte. |
| 4 | + |
| 5 | +```bash |
| 6 | +pip install "flyteplugins-webhooks-core[app]" flyteplugins-webhooks-jira |
| 7 | +``` |
| 8 | + |
| 9 | +## Using it |
| 10 | + |
| 11 | +Hand `PROVIDER` to a `WebhookAppEnvironment` and register handlers with the |
| 12 | +typed constants in `events`: |
| 13 | + |
| 14 | +```python |
| 15 | +import flyte |
| 16 | +from flyteplugins.webhooks.core import DuplicateRun, WebhookAppEnvironment, idempotent_run |
| 17 | +from flyteplugins.webhooks.jira import PROVIDER, events |
| 18 | + |
| 19 | +app_env = WebhookAppEnvironment( |
| 20 | + name="jira-webhooks", |
| 21 | + providers=[PROVIDER], |
| 22 | + secrets=[flyte.Secret("JIRA_WEBHOOK_TOKEN", as_env_var="JIRA_WEBHOOK_TOKEN")], |
| 23 | +) |
| 24 | + |
| 25 | + |
| 26 | +@app_env.on_event(events.Issue.CREATED) |
| 27 | +async def handle(event): |
| 28 | + import flyte.remote as remote |
| 29 | + |
| 30 | + task = remote.Task.get(name="my-env.my_task", auto_version="latest") |
| 31 | + try: |
| 32 | + run = await idempotent_run.aio(task, key=event.dedupe_key(), resource=event.resource_id) |
| 33 | + except DuplicateRun as exc: |
| 34 | + return {"skipped": str(exc)} |
| 35 | + return {"run": run.name} |
| 36 | + |
| 37 | + |
| 38 | +flyte.serve(app_env) |
| 39 | +``` |
| 40 | + |
| 41 | +Handlers must `await idempotent_run.aio(...)`. The blocking form stalls the |
| 42 | +app's event loop, and Jira times deliveries out in seconds. |
| 43 | + |
| 44 | +One app can serve several products at once — hand it more than one `PROVIDER`. |
| 45 | + |
| 46 | +## Setup |
| 47 | + |
| 48 | +1. Store the secret and mount it on the app: |
| 49 | + ```bash |
| 50 | + flyte create secret JIRA_WEBHOOK_TOKEN --value <secret> |
| 51 | + ``` |
| 52 | +2. Point Jira at `<app-url>/webhook/jira`, from |
| 53 | + Jira Settings → System → Webhooks. |
| 54 | + |
| 55 | +**Verification:** **None.** Jira Cloud does not sign its webhooks. |
| 56 | + |
| 57 | +Because there is no signature, this plugin authenticates with a shared token in `X-Webhook-Token` — which something in front of the app has to inject, since Jira cannot send custom headers. `PROVIDER.signed` is False, so the dashboard says the product does not sign rather than implying a guarantee that is absent. A shared token also cannot detect body tampering, only that the sender knew the token. |
| 58 | + |
| 59 | +## Event constants |
| 60 | + |
| 61 | +`events` spells every event this plugin can dispatch, as `str` enums grouped by |
| 62 | +event type, so a typo fails at import rather than by silently never matching. |
| 63 | +Raw strings still work, for events the constants do not cover yet. |
| 64 | + |
| 65 | +## What this plugin does not do |
| 66 | + |
| 67 | +Call the Jira API. Use the `jira` package directly from your tasks — see |
| 68 | +`examples/external_saas_integrations`. This plugin owns only the part that is |
| 69 | +Flyte's: authenticating an inbound delivery and turning it into a run. |
0 commit comments