Skip to main content

API Token Setup Guide

This guide explains how to configure API tokens for the JIRA automation pipeline using Bitbucket Repository Variables.

๐Ÿš€ Bitbucket Repository Variables Setupโ€‹

1. Access Repository Variablesโ€‹

  1. Go to your Bitbucket repository
  2. Click Repository settings (gear icon)
  3. Under PIPELINES, click Repository variables

2. Get Required API Tokensโ€‹

JIRA API Tokenโ€‹

  1. Go to Atlassian Account Settings
  2. Click Create API token
  3. Enter a label (e.g., "Documentation Automation")
  4. Copy the generated token

Anthropic API Keyโ€‹

  1. Go to Anthropic Console
  2. Navigate to API Keys
  3. Click Create Key
  4. Copy the key (starts with sk-ant-api03-)

Note: Claude Code CLI requires an API key for authentication in pipeline environments.

Bitbucket Access Tokenโ€‹

  1. Go to Bitbucket Settings โ†’ Personal Bitbucket settings
  2. Click App passwords
  3. Click Create app password
  4. Select permissions:
    • Repositories: Read, Write
    • Pull requests: Read, Write
    • Issues: Read (optional)
  5. Copy the generated password

3. Configure Repository Variablesโ€‹

Add these variables in Bitbucket Repository Variables:

Variable NameTypeValueDescription
JIRA_URLRegularhttps://superna.atlassian.netYour Atlassian instance URL
JIRA_EMAILRegularyour-email@superna.comYour Superna email address
JIRA_API_TOKENSecuredATATT3xFfGF0...Your JIRA API token
ANTHROPIC_API_KEYSecuredsk-ant-api03-...Your Anthropic API key
BITBUCKET_TOKENSecuredyour-app-passwordBitbucket app password
BITBUCKET_WORKSPACERegularsupernaBitbucket workspace
BITBUCKET_REPO_SLUGRegularpublic-documentationRepository name
DEFAULT_REVIEWERSRegularjohn.doe,jane.smithDefault PR reviewers (optional)

Important: Mark sensitive tokens as Secured to encrypt them.

4. Firebase Variables (Already Configured)โ€‹

These should already exist for your Firebase deployment:

  • FIREBASE_SERVICE_ACCOUNT_ENCODED (Secured)

๐Ÿ”ง Pipeline Integrationโ€‹

The pipeline will automatically use these variables when running the auto-documentation scripts. No additional configuration needed.

Auto-Doc Branch Workflowโ€‹

  1. JIRA automation creates branch auto-doc/ISSUE-KEY
  2. Pipeline triggers automatically
  3. Scripts access Repository Variables
  4. Documentation generated and PR created
  5. JIRA updated with results

๐Ÿงช Testingโ€‹

The pipeline includes environment validation:

  • All required variables are checked
  • API connections are tested
  • Clear error messages if anything is missing

๐Ÿ”’ Security Best Practicesโ€‹

  • โœ… Use Secured variables for all API tokens
  • โœ… Limit API token permissions to minimum required
  • โœ… Use service accounts where possible
  • โœ… Regularly rotate API tokens
  • โœ… Monitor API token usage

๐Ÿ”ง Troubleshootingโ€‹

Common Issuesโ€‹

"Authentication failed"โ€‹

  • Verify your email and API token are correct in Repository Variables
  • Check if API token has expired
  • Ensure you're using the correct JIRA URL

"Pipeline fails during Claude Code CLI execution"โ€‹

  • Check pipeline logs for Claude Code CLI installation issues
  • Verify branch follows auto-doc/ISSUE-KEY format
  • Ensure JIRA issue has auto-doc label

"BITBUCKET_TOKEN environment variable is required"โ€‹

  • Verify the app password has correct permissions
  • Check if the token hasn't expired
  • Ensure variable is marked as Secured

Getting Helpโ€‹

  1. Check the pipeline logs in Bitbucket
  2. Verify all Repository Variables are configured
  3. Ensure Secured variables are properly encrypted

๐Ÿ“‹ Environment Variable Referenceโ€‹

VariableRequiredTypeDescriptionExample
JIRA_URLYesRegularYour Atlassian instance URLhttps://superna.atlassian.net
JIRA_EMAILYesRegularYour Atlassian account emailuser@superna.com
JIRA_API_TOKENYesSecuredJIRA API tokenATATT3xFfGF0...
ANTHROPIC_API_KEYYesSecuredAnthropic API keysk-ant-api03-...
BITBUCKET_TOKENYesSecuredBitbucket app passwordyour-app-password
BITBUCKET_WORKSPACENoRegularBitbucket workspacesuperna (default)
BITBUCKET_REPO_SLUGNoRegularRepository namepublic-documentation (default)
DEFAULT_REVIEWERSNoRegularDefault PR reviewersjohn.doe,jane.smith