Plan — BJ-4: Config schema Bitbucket + Jira env blocks#
Summary#
Add conditionally-validated Bitbucket and Jira env var blocks to src/config/config.schema.ts, mirroring the existing GITHUB_APP_* Joi.when() pattern so empty Atlassian config stays backward-compatible and partial configs fail fast with a clear error. Document both blocks in .env.example.
Files#
| Path | Action | Purpose |
|---|---|---|
src/config/config.schema.ts | modify | Append Bitbucket + Jira Joi entries; gate companions on BITBUCKET_OAUTH_CLIENT_ID / JIRA_OAUTH_CLIENT_ID via .when() |
src/config/config.schema.spec.ts | modify | Add Bitbucket mode and Jira mode describe blocks mirroring the existing GitHub App mode tests |
.env.example | modify | Append two commented blocks documenting Bitbucket and Jira vars |
Steps#
- In
config.schema.ts, addBITBUCKET_OAUTH_CLIENT_ID: Joi.string().optional()plusBITBUCKET_OAUTH_CLIENT_SECRET,BITBUCKET_OAUTH_REFRESH_TOKEN,BITBUCKET_WORKSPACEeach asJoi.string().when('BITBUCKET_OAUTH_CLIENT_ID', { is: Joi.exist(), then: Joi.required(), otherwise: Joi.optional() }). - Add the remaining Bitbucket vars (
BITBUCKET_REPO,BITBUCKET_BOT_USERNAME,BITBUCKET_WEBHOOK_SECRET) as plainJoi.string().optional()— scope lists them but only CLIENT_ID/SECRET/REFRESH_TOKEN/WORKSPACE are required companions per the issue spec. - Repeat the same pattern for Jira:
JIRA_OAUTH_CLIENT_IDtriggers required status onJIRA_OAUTH_CLIENT_SECRET,JIRA_OAUTH_REFRESH_TOKEN,JIRA_SITE_URL,JIRA_CLOUD_ID. AddJIRA_PROJECT_KEY,JIRA_BOT_USERNAME,JIRA_WEBHOOK_SECRETas plain optional. - In
config.schema.spec.ts, add aBitbucket modedescribe: (a) empty Atlassian config passes, (b) onlyBITBUCKET_OAUTH_CLIENT_IDset fails and the error lists the three missing companions, (c) all four required companions set passes. - Add a matching
Jira modedescribe following the same three cases with the four Jira companions. - Append two blocks to
.env.exampleunder new# --- Bitbucket (optional) ---and# --- Jira (optional) ---headers, with inline comments flagging the trigger var and required companions; leave all lines commented out so GitHub-only deployments keep defaulting off.
Verification#
npm run test -- config.schema.specpasses; new describe blocks cover empty / partial-fail / complete-pass cases.npm run lintandnpm run buildare clean.- Running the app with an empty Atlassian section still boots (no regression for existing
validEnvfixture).
Risks#
- Using only
CLIENT_IDas the.when()trigger means a user who sets e.g. onlyBITBUCKET_OAUTH_CLIENT_SECRETwill not get a validation error. This matches theGITHUB_APP_IDpattern already in the repo and is intentional — keeping one designated gateway var keeps error messages clean.
Assumptions#
- Trigger vars are
BITBUCKET_OAUTH_CLIENT_IDandJIRA_OAUTH_CLIENT_ID(the issue explicitly marks them as the "required together with …" anchors). *_REFRESH_TOKENis a bootstrap string only — no format validation required per issue edge case note.- The six non-companion vars (
BITBUCKET_REPO,*_BOT_USERNAME,*_WEBHOOK_SECRET,JIRA_PROJECT_KEY) stay plain.optional()at this phase; downstream waves can tighten later.