Bitbucket
Connect Code Search to Bitbucket Cloud or Bitbucket Server (Data Center).
Bitbucket Cloud
Section titled “Bitbucket Cloud”Creating an App Password
Section titled “Creating an App Password”-
Click Create app password
-
Give it a label:
Code Search -
Select permissions:
- Repositories: Read
- Workspaces: Read (optional)
-
Click Create
-
Copy the password immediately
Adding the Connection
Section titled “Adding the Connection”Via Web UI
Section titled “Via Web UI”- Go to Connections → Add Connection
- Fill in:
- Name:
Bitbucket - Type:
Bitbucket - URL:
https://api.bitbucket.org/2.0 - Username: Your Bitbucket username
- Token: Your app password
- Name:
- Click Test Connection
- Click Create
Via API
Section titled “Via API”curl -X POST "http://localhost:8080/api/v1/connections" \ -H "Content-Type: application/json" \ -d '{ "name": "Bitbucket", "type": "bitbucket", "url": "https://api.bitbucket.org/2.0", "username": "your-username", "token": "your-app-password" }'Via Configuration File
Section titled “Via Configuration File”Add code hosts to your config.yaml:
codehosts: # The key is the connection name bitbucket: type: bitbucket url: "https://api.bitbucket.org/2.0" username: "$CS_BITBUCKET_USERNAME" # Environment variable reference token: "$CS_BITBUCKET_TOKEN" # App password exclude_archived: true # Skip archived repos during syncWith environment variables:
export CS_BITBUCKET_USERNAME="your-username"export CS_BITBUCKET_TOKEN="your-app-password"Bitbucket Server / Data Center
Section titled “Bitbucket Server / Data Center”Creating a Personal Access Token
Section titled “Creating a Personal Access Token”-
Go to your Bitbucket Server instance
-
Navigate to Manage account → Personal access tokens
-
Click Create a token
-
Configure:
- Name:
Code Search - Permissions: Repository read
- Name:
-
Click Create
-
Copy the token
Adding the Connection
Section titled “Adding the Connection”Via API
Section titled “Via API”curl -X POST "http://localhost:8080/api/v1/connections" \ -H "Content-Type: application/json" \ -d '{ "name": "Bitbucket Server", "type": "bitbucket_server", "url": "https://bitbucket.yourcompany.com", "token": "your-personal-access-token" }'Via Configuration File
Section titled “Via Configuration File”codehosts: bitbucket-server: type: bitbucket_server url: "https://bitbucket.yourcompany.com" token: "$CS_BITBUCKET_SERVER_TOKEN" # Personal access token exclude_archived: trueURL Configuration
Section titled “URL Configuration”https://api.bitbucket.org/2.0 Use your instance URL: https://bitbucket.yourcompany.com
App Password Permissions
Section titled “App Password Permissions”Minimum Required
Section titled “Minimum Required”| Permission | Purpose |
|---|---|
| Repositories: Read | Clone and read repositories |
For Replace Feature
Section titled “For Replace Feature”| Permission | Purpose |
|---|---|
| Repositories: Write | Push branches for replace |
| Pull requests: Write | Create pull requests |
Optional
Section titled “Optional”| Permission | Purpose |
|---|---|
| Workspaces: Read | List workspaces |
| Pull requests: Read | Read PR information |
Repository Discovery
Section titled “Repository Discovery”Bitbucket Cloud
Section titled “Bitbucket Cloud”Code Search discovers repositories from:
- Personal workspace
- Team workspaces you’re a member of
Bitbucket Server
Section titled “Bitbucket Server”Code Search discovers:
- Projects you have access to
- Personal repositories
Syncing Repositories
Section titled “Syncing Repositories”After adding the connection:
- Click Sync on the connection card
- Code Search discovers your repositories
- Repositories are queued for indexing
Filtering Repositories
Section titled “Filtering Repositories”You can exclude archived repositories using the exclude_archived: true option in your configuration (shown above in the Configuration File sections).
Authentication
Section titled “Authentication”Bitbucket Cloud
Section titled “Bitbucket Cloud”Uses app password with username:
- Username: Your Bitbucket username (not email)
- Password: App password
Bitbucket Server
Section titled “Bitbucket Server”Options:
- Personal Access Token (recommended)
- Username/Password (legacy)
Troubleshooting
Section titled “Troubleshooting”Authentication failed
Section titled “Authentication failed”401 UnauthorizedBitbucket Cloud:
- Verify username is your Bitbucket username, not email
- Check app password is correct
- Ensure app password has required permissions
Bitbucket Server:
- Verify personal access token is correct
- Check token hasn’t expired
Workspace not found
Section titled “Workspace not found”404 Workspace not found- Verify workspace name is correct
- Ensure you’re a member of the workspace
- Check app password has workspace read permission
Rate limits
Section titled “Rate limits”Bitbucket Cloud has API rate limits. If you hit them:
- Reduce sync frequency
- Wait for limit reset
SSH keys
Section titled “SSH keys”Code Search uses HTTPS for cloning. SSH is not supported.
Bitbucket Pipelines
Section titled “Bitbucket Pipelines”For CI/CD integration, you can trigger syncs from Bitbucket Pipelines:
pipelines: custom: sync-code-search: - step: script: - curl -X POST "https://code-search.example.com/api/v1/connections/1/sync"Limitations
Section titled “Limitations”- Archived repositories: Bitbucket API doesn’t expose archived status, so
exclude_archivedhas no effect for Bitbucket connections - SSH cloning: Not supported - Code Search uses HTTPS with app passwords
Next Steps
Section titled “Next Steps”- GitHub - Connect to GitHub
- Configuration - Connection settings