enhancementgood first issueintegrationnew-featurenew-integration
Metriche repository
- Star
- (1930 stelle)
- Metriche merge PR
- (Metriche PR in attesa)
Descrizione
Description
Add Bitbucket integration to sync repositories, pull requests, commits, issues, and pipelines into CORE.
Reference Implementations
Existing Integrations (use as templates)
integrations/github/- Directly comparable Git hosting platformintegrations/linear/- For issue tracking patternsintegrations/slack/- For reference
Required Files Structure
integrations/bitbucket/
├── src/
│ ├── index.ts # Main entry, OAuth spec
│ ├── schedule.ts # Sync logic
│ ├── utils.ts # Bitbucket API utilities
│ ├── account-create.ts # OAuth setup
│ └── create-activity.ts # Activity formatting
├── package.json
├── tsup.config.ts
└── README.md
Bitbucket API Integration
OAuth Setup
- Use OAuth 2.0 (Authorization Code Grant)
- API Version: 2.0
- Base URL:
https://api.bitbucket.org/2.0/ - Authorization URL:
https://bitbucket.org/site/oauth2/authorize - Token URL:
https://bitbucket.org/site/oauth2/access_token - Required scopes:
repository- Read access to repositoriesrepository:write- Write access to repositoriespullrequest- Read access to pull requestspullrequest:write- Write access to pull requestsissue- Read access to issuesissue:write- Write access to issuespipeline- Read access to pipelinesaccount- Read access to account informationwebhook- Manage webhooks
Key Endpoints
GET /2.0/repositories/{workspace}/{repo_slug}- Get repositoryGET /2.0/repositories/{workspace}/{repo_slug}/pullrequests- List pull requestsGET /2.0/repositories/{workspace}/{repo_slug}/commits- List commitsGET /2.0/repositories/{workspace}/{repo_slug}/issues- List issuesGET /2.0/repositories/{workspace}/{repo_slug}/pipelines- List pipelinesGET /2.0/repositories/{workspace}/{repo_slug}/src- Browse sourceGET /2.0/repositories/{workspace}- List workspace repositoriesGET /2.0/workspaces- List workspacesGET /2.0/repositories/{workspace}/{repo_slug}/refs/branches- List branchesGET /2.0/repositories/{workspace}/{repo_slug}/deploy-keys- List deploy keys
Events to Track
-
Pull Requests
- PR created, updated, merged, declined
- PR comments and approvals
- PR build status changes
- Code review activity
-
Commits & Code
- New commits pushed
- Branch created/deleted
- Tag created
- Repository forked
-
Issues & Pipelines
- Issue created, updated, resolved
- Pipeline started, completed, failed
- Deployment events
Implementation Tasks
- Set up basic integration structure following
integrations/github/src/index.tspattern - Implement OAuth 2.0 flow in
account-create.ts - Create Bitbucket API utilities in
utils.ts - Implement sync logic in
schedule.ts - Convert Bitbucket events to CORE activity format
- Add error handling and rate limiting
- Create integration documentation
- Add to
integrations/README.md
Technical Notes
- Bitbucket Cloud REST API v1.0 is deprecated. Always use v2.0.
- Rate limiting: 1,000 requests per hour for authenticated requests.
- Pagination uses
pageandpagelenparameters withnext/previouslinks in response. - Webhooks support over 30 event types for real-time notifications.
- Bitbucket is owned by Atlassian; OAuth consumers are created in workspace settings.
- Access tokens expire after 2 hours; refresh tokens should be used for renewal.
- The API supports workspace-level and repository-level resources.
Resources
- Bitbucket Cloud REST API
- About Bitbucket Cloud REST API
- Bitbucket Cloud REST API Scopes
- Bitbucket OAuth
- Bitbucket Webhooks
Labels
enhancement, integration, new-feature