Skip to content

Commit 9467a94

Browse files
authored
docs(jira): align setup guide with implemented behavior (#552) (#554)
Fixes from a live setup walkthrough on a dev stack: - Prerequisites: state the stack must include the Jira integration (#302) — pre-#302 stacks have no Jira resources and need a redeploy - Step 2: note on the stalled 'Waiting for browser callback' state and that re-running setup is safe/idempotent (+ troubleshooting entry) - Step 4: point at setup's ready-to-paste Next-steps map command; add cloudId recovery via _edge/tenant_info or the workspace registry - Step 5: document the interim manual user-mapping put-item with the exact row shape jira-link.ts writes, how to find the Atlassian accountId and Cognito sub, and cross-link #553 (invite-user); call out the dead-end 'run jira link' comment for unlinked users - Troubleshooting: new '401 calling the API right after setup' entry — ~1h token life, Lambda-side refresh on next webhook, manual-refresh hazards (refresh-token rotation, webhook_signing_secret preservation) - Diagram: POST /jira/webhook → POST /v1/jira/webhook (stage prefix) Starlight mirror regenerated via mise //docs:sync.
1 parent 3cc65b5 commit 9467a94

2 files changed

Lines changed: 74 additions & 8 deletions

File tree

docs/guides/JIRA_SETUP_GUIDE.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Set up the ABCA Jira Cloud integration so that adding a label to a Jira issue tr
44

55
## Prerequisites
66

7-
- ABCA CDK stack deployed (see [Developer guide](./DEVELOPER_GUIDE.md))
7+
- ABCA CDK stack deployed **at a version that includes the Jira integration** ([#302](https://github.com/aws-samples/sample-autonomous-cloud-coding-agents/pull/302), merged 2026-06-17) — a stack deployed before that has no Jira resources and needs a sync + redeploy first (see [Developer guide](./DEVELOPER_GUIDE.md))
88
- A Cognito user account configured (see [User guide](./USER_GUIDE.md))
99
- A Jira Cloud site where you have **admin** access (to create the OAuth app and the webhook)
1010
- The `bgagent` CLI installed and logged in (`bgagent configure` + `bgagent login`)
@@ -21,7 +21,7 @@ Inbound (Jira → ABCA):
2121

2222
```
2323
Jira Cloud webhook
24-
→ POST /jira/webhook (API GW, no Cognito, HMAC-verified)
24+
→ POST /v1/jira/webhook (API GW, no Cognito, HMAC-verified)
2525
→ JiraWebhookFn (verify X-Hub-Signature, dedup, async invoke)
2626
→ JiraWebhookProcessorFn (resolve tenant OAuth, look up project→repo,
2727
build task, call createTaskCore)
@@ -88,6 +88,8 @@ This runs the OAuth 3LO dance:
8888
4. If your account can access multiple Atlassian sites, the CLI lists them and asks you to pick one. It records the selected site's `cloud_id` and `site_url`.
8989
5. Stores the OAuth token bundle in `bgagent-jira-oauth-<cloudId>` and records the tenant in the workspace registry.
9090

91+
> **If `setup` hangs at "Waiting for browser callback…"** the consent redirect never reached the CLI's localhost listener. Usual causes: the consent tab was completed in a *different* browser/profile than the one `setup` opened, the tab was closed before clicking Authorize, or something else is bound to port 8080. Ctrl-C and re-run `bgagent jira setup` — re-running is safe and idempotent (it re-mints the token bundle and re-registers the tenant; nothing is half-written by an aborted attempt).
92+
9193
### 3. Configure the Jira webhook
9294

9395
`setup` then prompts for a **webhook signing secret**. Unlike Linear, Atlassian does **not** auto-generate one — the operator chooses it at webhook-create time. In a second terminal, open **Jira → Settings → System → Webhooks → Create a Webhook** and enter:
@@ -104,7 +106,7 @@ Paste that same secret value back at the `Webhook signing secret:` prompt. ABCA
104106
bgagent jira map <cloud-id> <PROJECT-KEY> --repo owner/repo
105107
```
106108

107-
- `<cloud-id>` — the tenant UUID `setup` printed (`cloud_id: …`)
109+
- `<cloud-id>` — the tenant UUID. `setup`'s final **Next steps** block prints this exact `map` command with the cloudId pre-filled — paste it and swap in your project key and repo. If that terminal output is gone, recover the cloudId from `https://<your-site>.atlassian.net/_edge/tenant_info` (returns it as JSON) or from the workspace-registry table — it is *not* shown anywhere in the Jira UI
108110
- `<PROJECT-KEY>` — the Jira project key, e.g. `ENG` (uppercase, starts with a letter)
109111
- `--repo owner/repo` — the GitHub repository tasks from this project route to
110112
- `--label <name>` — trigger label (default `bgagent`)
@@ -121,7 +123,28 @@ bgagent jira link <code>
121123

122124
The CLI shows the Jira identity (name + email) and the tenant, and asks for confirmation **before** writing the mapping row — so a mis-issued code is caught before it binds.
123125

124-
> The `invite-user` issuing command is not yet implemented. Until it lands, an admin can populate the user-mapping row manually (`accountId` → platform user id) for the tenant.
126+
> The `invite-user` issuing command is not yet implemented (tracked in [#553](https://github.com/aws-samples/sample-autonomous-cloud-coding-agents/issues/553)). Until it lands, an admin can write the user-mapping row directly. Note that until the row exists, a labeled issue from the unlinked user produces no task — the processor comments "Run `bgagent jira link <code>`" on the issue, but no code can be issued yet.
127+
128+
**Interim manual linking (admin IAM).** Write an `active` row to the user-mapping table (stack output `JiraUserMappingTableName`), keyed exactly as `jira-link.ts` would write it:
129+
130+
```bash
131+
aws dynamodb put-item \
132+
--table-name <JiraUserMappingTableName> \
133+
--item '{
134+
"jira_identity": {"S": "<cloudId>#<accountId>"},
135+
"platform_user_id": {"S": "<cognito-sub>"},
136+
"jira_cloud_id": {"S": "<cloudId>"},
137+
"jira_account_id": {"S": "<accountId>"},
138+
"linked_at": {"S": "<ISO-8601 timestamp>"},
139+
"status": {"S": "active"},
140+
"link_method": {"S": "manual"}
141+
}'
142+
```
143+
144+
Where to find the two identity values:
145+
146+
- **Atlassian `accountId`** — open your Jira profile (avatar → Profile); the URL ends `/people/<accountId>`. Or call `GET https://api.atlassian.com/ex/jira/<cloudId>/rest/api/3/myself` with the stored token.
147+
- **Cognito sub (platform user id)**`aws cognito-idp admin-get-user --user-pool-id <pool> --username <email> --query 'UserAttributes[?Name==`sub`].Value' --output text`.
125148

126149
### 6. Test
127150

@@ -173,6 +196,16 @@ aws secretsmanager get-secret-value \
173196
--query SecretString --output text | jq .webhook_signing_secret
174197
```
175198

199+
### `setup` hangs at "Waiting for browser callback…"
200+
201+
The consent redirect never reached the CLI's localhost listener — see the note under [Step 2](#2-authorize-the-app-on-the-tenant). Ctrl-C and re-run `bgagent jira setup`; re-running is safe.
202+
203+
### 401 when calling the Jira API directly after setup
204+
205+
Expected, not a broken install. The stored access token lives ~1 hour and is only refreshed by the **trusted Lambda paths** when they next run — i.e. on the next webhook delivery (see [Limits and quotas](#limits-and-quotas)). If you fetch the token from Secrets Manager right after `setup` to verify it and get a 401, the integration is still fine: add the trigger label to an issue and the processor will refresh the bundle before using it.
206+
207+
**Do not refresh the token manually.** Atlassian rotates the `refresh_token` on every use, and the rotated bundle must be written back to Secrets Manager *preserving every other field* — in particular `webhook_signing_secret`. A manual refresh that drops a field or loses the rotated refresh token bricks the tenant install (the only recovery is re-running `bgagent jira setup`). If you need a live token for debugging, trigger a label event and read the bundle the Lambda just wrote.
208+
176209
### Agent doesn't comment back on Jira
177210

178211
- Verify the per-tenant OAuth secret exists: `aws secretsmanager describe-secret --secret-id bgagent-jira-oauth-<cloudId>`.

docs/src/content/docs/using/Jira-setup-guide.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Set up the ABCA Jira Cloud integration so that adding a label to a Jira issue tr
88

99
## Prerequisites
1010

11-
- ABCA CDK stack deployed (see [Developer guide](/sample-autonomous-cloud-coding-agents/developer-guide/introduction))
11+
- ABCA CDK stack deployed **at a version that includes the Jira integration** ([#302](https://github.com/aws-samples/sample-autonomous-cloud-coding-agents/pull/302), merged 2026-06-17) — a stack deployed before that has no Jira resources and needs a sync + redeploy first (see [Developer guide](/sample-autonomous-cloud-coding-agents/developer-guide/introduction))
1212
- A Cognito user account configured (see [User guide](/sample-autonomous-cloud-coding-agents/using/overview))
1313
- A Jira Cloud site where you have **admin** access (to create the OAuth app and the webhook)
1414
- The `bgagent` CLI installed and logged in (`bgagent configure` + `bgagent login`)
@@ -25,7 +25,7 @@ Inbound (Jira → ABCA):
2525

2626
```
2727
Jira Cloud webhook
28-
→ POST /jira/webhook (API GW, no Cognito, HMAC-verified)
28+
→ POST /v1/jira/webhook (API GW, no Cognito, HMAC-verified)
2929
→ JiraWebhookFn (verify X-Hub-Signature, dedup, async invoke)
3030
→ JiraWebhookProcessorFn (resolve tenant OAuth, look up project→repo,
3131
build task, call createTaskCore)
@@ -92,6 +92,8 @@ This runs the OAuth 3LO dance:
9292
4. If your account can access multiple Atlassian sites, the CLI lists them and asks you to pick one. It records the selected site's `cloud_id` and `site_url`.
9393
5. Stores the OAuth token bundle in `bgagent-jira-oauth-<cloudId>` and records the tenant in the workspace registry.
9494

95+
> **If `setup` hangs at "Waiting for browser callback…"** the consent redirect never reached the CLI's localhost listener. Usual causes: the consent tab was completed in a *different* browser/profile than the one `setup` opened, the tab was closed before clicking Authorize, or something else is bound to port 8080. Ctrl-C and re-run `bgagent jira setup` — re-running is safe and idempotent (it re-mints the token bundle and re-registers the tenant; nothing is half-written by an aborted attempt).
96+
9597
### 3. Configure the Jira webhook
9698

9799
`setup` then prompts for a **webhook signing secret**. Unlike Linear, Atlassian does **not** auto-generate one — the operator chooses it at webhook-create time. In a second terminal, open **Jira → Settings → System → Webhooks → Create a Webhook** and enter:
@@ -108,7 +110,7 @@ Paste that same secret value back at the `Webhook signing secret:` prompt. ABCA
108110
bgagent jira map <cloud-id> <PROJECT-KEY> --repo owner/repo
109111
```
110112

111-
- `<cloud-id>` — the tenant UUID `setup` printed (`cloud_id: …`)
113+
- `<cloud-id>` — the tenant UUID. `setup`'s final **Next steps** block prints this exact `map` command with the cloudId pre-filled — paste it and swap in your project key and repo. If that terminal output is gone, recover the cloudId from `https://<your-site>.atlassian.net/_edge/tenant_info` (returns it as JSON) or from the workspace-registry table — it is *not* shown anywhere in the Jira UI
112114
- `<PROJECT-KEY>` — the Jira project key, e.g. `ENG` (uppercase, starts with a letter)
113115
- `--repo owner/repo` — the GitHub repository tasks from this project route to
114116
- `--label <name>` — trigger label (default `bgagent`)
@@ -125,7 +127,28 @@ bgagent jira link <code>
125127

126128
The CLI shows the Jira identity (name + email) and the tenant, and asks for confirmation **before** writing the mapping row — so a mis-issued code is caught before it binds.
127129

128-
> The `invite-user` issuing command is not yet implemented. Until it lands, an admin can populate the user-mapping row manually (`accountId` → platform user id) for the tenant.
130+
> The `invite-user` issuing command is not yet implemented (tracked in [#553](https://github.com/aws-samples/sample-autonomous-cloud-coding-agents/issues/553)). Until it lands, an admin can write the user-mapping row directly. Note that until the row exists, a labeled issue from the unlinked user produces no task — the processor comments "Run `bgagent jira link <code>`" on the issue, but no code can be issued yet.
131+
132+
**Interim manual linking (admin IAM).** Write an `active` row to the user-mapping table (stack output `JiraUserMappingTableName`), keyed exactly as `jira-link.ts` would write it:
133+
134+
```bash
135+
aws dynamodb put-item \
136+
--table-name <JiraUserMappingTableName> \
137+
--item '{
138+
"jira_identity": {"S": "<cloudId>#<accountId>"},
139+
"platform_user_id": {"S": "<cognito-sub>"},
140+
"jira_cloud_id": {"S": "<cloudId>"},
141+
"jira_account_id": {"S": "<accountId>"},
142+
"linked_at": {"S": "<ISO-8601 timestamp>"},
143+
"status": {"S": "active"},
144+
"link_method": {"S": "manual"}
145+
}'
146+
```
147+
148+
Where to find the two identity values:
149+
150+
- **Atlassian `accountId`** — open your Jira profile (avatar → Profile); the URL ends `/people/<accountId>`. Or call `GET https://api.atlassian.com/ex/jira/<cloudId>/rest/api/3/myself` with the stored token.
151+
- **Cognito sub (platform user id)**`aws cognito-idp admin-get-user --user-pool-id <pool> --username <email> --query 'UserAttributes[?Name==`sub`].Value' --output text`.
129152

130153
### 6. Test
131154

@@ -177,6 +200,16 @@ aws secretsmanager get-secret-value \
177200
--query SecretString --output text | jq .webhook_signing_secret
178201
```
179202

203+
### `setup` hangs at "Waiting for browser callback…"
204+
205+
The consent redirect never reached the CLI's localhost listener — see the note under [Step 2](#2-authorize-the-app-on-the-tenant). Ctrl-C and re-run `bgagent jira setup`; re-running is safe.
206+
207+
### 401 when calling the Jira API directly after setup
208+
209+
Expected, not a broken install. The stored access token lives ~1 hour and is only refreshed by the **trusted Lambda paths** when they next run — i.e. on the next webhook delivery (see [Limits and quotas](#limits-and-quotas)). If you fetch the token from Secrets Manager right after `setup` to verify it and get a 401, the integration is still fine: add the trigger label to an issue and the processor will refresh the bundle before using it.
210+
211+
**Do not refresh the token manually.** Atlassian rotates the `refresh_token` on every use, and the rotated bundle must be written back to Secrets Manager *preserving every other field* — in particular `webhook_signing_secret`. A manual refresh that drops a field or loses the rotated refresh token bricks the tenant install (the only recovery is re-running `bgagent jira setup`). If you need a live token for debugging, trigger a label event and read the bundle the Lambda just wrote.
212+
180213
### Agent doesn't comment back on Jira
181214

182215
- Verify the per-tenant OAuth secret exists: `aws secretsmanager describe-secret --secret-id bgagent-jira-oauth-<cloudId>`.

0 commit comments

Comments
 (0)