Documentation
Bitbucket Integration
Jetscale integrates with Bitbucket to automatically create pull requests containing production-ready Terraform code for your cost optimization recommendations.
Jetscale integrates with Bitbucket to automatically create pull requests containing production-ready Terraform code for your cost optimization recommendations.
Overview
The Bitbucket integration allows Jetscale to:
- Push generated Terraform code to your Bitbucket repositories
- Create pull requests with detailed optimization recommendations
- Integrate seamlessly with your existing code review and CI/CD workflows
- Track recommendation implementation status through Bitbucket pipelines
Prerequisites
Before connecting Bitbucket, you'll need:
- Bitbucket Account (Cloud or Server)
- Repository Access with write permissions
- App Password or Personal Access Token with appropriate scopes
Supported Bitbucket Versions
- Bitbucket Cloud (bitbucket.org) - Recommended
- Bitbucket Server / Data Center (self-hosted)
Setup Guide
Step 1: Create a Bitbucket App Password
Image pending: Bitbucket App Password Creation Screenshot placeholder: Bitbucket app password settings
For Bitbucket Cloud
- Navigate to Bitbucket Settings → App passwords
- Click Create app password
- Give it a descriptive label (e.g., "Jetscale Integration")
- Select the required permissions:
- ✓ Account: Read
- ✓ Workspace membership: Read
- ✓ Projects: Read
- ✓ Repositories: Write
- ✓ Pull requests: Write
- Click Create
- Important: Copy your app password immediately - you won't see it again
For Bitbucket Server
- Navigate to Profile Settings → Personal access tokens
- Click Create a token
- Give it a name (e.g., "Jetscale")
- Select permissions:
- ✓ Repository read
- ✓ Repository write
- Set expiration date
- Click Create
- Copy your token
Security Note: Store your app password or token securely. Jetscale encrypts credentials at rest.
Step 2: Connect Bitbucket in Jetscale
Image pending: Bitbucket Connection Screen Screenshot placeholder: Jetscale Bitbucket integration page
- Navigate to Settings → Integrations in Jetscale
- Click Connect Bitbucket
- Enter your configuration:
- Bitbucket Type: Cloud or Server
- Server URL: (For Bitbucket Server only) e.g.,
https://bitbucket.yourcompany.com - Username: Your Bitbucket username
- App Password/Token: The credential created in Step 1
- Click Verify and Connect
Jetscale will verify your credentials and display your accessible repositories.
Step 3: Select Your Repository
Image pending: Repository Selection Screenshot placeholder: Bitbucket repository selection dropdown
- From the Repository dropdown, select your Terraform infrastructure repository
- Format:
workspace/repository-slug(Cloud) orproject/repository(Server) - Jetscale will verify you have write access
- Click Save
The selected repository will be used for all future pull requests.
How It Works
Pull Request Creation
When you approve a cost optimization recommendation in Jetscale:
- Branch Creation: Jetscale creates a new feature branch from your default branch (usually
mainormaster)- Branch naming:
jetscale/optimization-{resource-type}-{timestamp} - Example:
jetscale/optimization-rds-20240115-143022
- Branch naming:
- File Push: Generated Terraform files are committed to the branch
- Files placed in
terraform/directory - Commit message includes optimization summary and cost impact
- Files placed in
- Pull Request: A PR is automatically created with:
- Title: Concise optimization description
- Description: Detailed cost analysis, performance considerations, implementation steps
- Reviewers: Automatically added based on repository settings (optional)
Pull Request Structure
# Cost Optimization: RDS Instance Right-Sizing
## Summary
Downgrade RDS instance `production-db` from **db.r5.2xlarge** to **db.r5.xlarge**
## Cost Impact
| Metric | Current | Projected | Savings |
|--------|---------|-----------|---------|
| Monthly Cost | $730.00 | $365.00 | **$365.00 (50%)** |
| Annual Cost | $8,760.00 | $4,380.00 | **$4,380.00** |
## Performance Analysis
✓ Current CPU utilization: 15-25% average
✓ Current memory utilization: 30-40% average
✓ Recommended instance provides 2x current peak usage
✓ **Risk Assessment**: Low - No performance degradation expected
## Files Changed
- `terraform/rds_production_db.tf` - Updated instance class from db.r5.2xlarge to db.r5.xlarge
- `terraform/variables.tf` - Added configurable instance_class variable
## Implementation Checklist
- [ ] Review changes in Terraform plan output
- [ ] Apply to staging environment first
- [ ] Monitor performance for 24-48 hours
- [ ] Verify application health checks pass
- [ ] Apply to production with change management approval
## Testing Recommendations
1. Run `terraform plan` to preview changes
2. Check for any dependent resources
3. Verify backup/snapshot policies
4. Confirm monitoring dashboards are updated
---
🤖 Generated by [Jetscale](https://jetscale.ai) | [View in Jetscale Dashboard](#)
Terraform Code Example
# Optimized RDS instance configuration
# Generated by Jetscale on 2024-01-15
resource "aws_db_instance" "production_db" {
identifier = "production-db"
engine = "postgres"
engine_version = "14.7"
# Previous: db.r5.2xlarge ($730/month)
# New: db.r5.xlarge ($365/month)
# Cost Reduction: 50% ($365/month, $4,380/year)
#
# Justification:
# - Average CPU utilization: 15-25%
# - Average memory utilization: 30-40%
# - New instance provides 2x headroom above peak usage
instance_class = var.rds_production_instance_class
allocated_storage = 100
storage_type = "gp3"
storage_encrypted = true
# ... other configuration unchanged
}
Repository Permissions
Jetscale requires write access to your repository to create branches and pull requests. The integration will:
✓ Create feature branches ✓ Commit Terraform files ✓ Create pull requests ✓ Read repository metadata and branches
✗ Cannot merge pull requests ✗ Cannot delete branches ✗ Cannot modify settings or webhooks ✗ Cannot access repository secrets or pipeline variables
Bitbucket Pipeline Integration
Automatic Validation
Jetscale pull requests trigger your existing Bitbucket Pipelines:
# bitbucket-pipelines.yml example
pipelines:
pull-requests:
'**':
- step:
name: Validate Terraform
script:
- terraform init
- terraform fmt -check
- terraform validate
- terraform plan
Status Checks
Jetscale monitors pipeline status:
- ✅ All checks passed: Ready to merge
- ⚠️ Checks pending: Waiting for pipeline
- ❌ Checks failed: Review pipeline logs
Managing the Integration
View Integration Status
From Settings → Integrations → Bitbucket:
- Connected Bitbucket account
- Server URL (if Bitbucket Server)
- Selected workspace/project and repository
- Last verification time
- Recent pull requests created
Change Repository
- Navigate to Settings → Integrations → Bitbucket
- Click Change Repository
- Select a different repository
- Click Update
Update Credentials
If your app password or token expires:
- Generate a new app password/token in Bitbucket
- Navigate to Settings → Integrations → Bitbucket
- Click Update Credentials
- Enter new credentials
- Click Save and Verify
Disconnect Bitbucket
To remove the integration:
- Navigate to Settings → Integrations → Bitbucket
- Click Disconnect
- Confirm disconnection
Important: Disconnecting will:
- Remove stored credentials from Jetscale
- Stop automatic PR creation
- Preserve existing pull requests in Bitbucket
Troubleshooting
Authentication Failed
Problem: "Invalid credentials" error when connecting
Solutions:
- Verify username is correct (case-sensitive)
- Check app password/token hasn't expired
- Ensure all required scopes are selected
- For Bitbucket Server, verify server URL is correct and accessible
- Try creating a new app password
Repository Not Found
Problem: Can't find repository in selection dropdown
Solutions:
- Verify you have write access to the repository
- Check repository isn't archived
- Ensure workspace/project membership is active
- For Bitbucket Server, confirm project permissions
- Try refreshing the repository list
Pull Request Creation Failed
Problem: Recommendation approved but PR wasn't created
Solutions:
- Verify branch doesn't already exist with same name
- Check you still have write access
- Ensure default branch exists and isn't locked
- Confirm repository isn't in read-only mode
- Review Bitbucket API rate limits
Pipeline Not Triggering
Problem: Bitbucket Pipelines doesn't run on Jetscale PRs
Solutions:
- Verify Pipelines are enabled for the repository
- Check
bitbucket-pipelines.ymlincludes pull-request triggers - Ensure pipeline quota isn't exhausted
- Review branch pattern matching in pipeline configuration
Best Practices
Credential Management
- Dedicated app password: Create separate credentials for Jetscale
- Set expiration: Use reasonable expiration dates (90-180 days)
- Rotate regularly: Update credentials before expiry
- Revoke unused: Delete old app passwords immediately
Repository Configuration
- Branch protection: Require reviews on default branch
- Required reviewers: Configure CODEOWNERS for automatic review assignment
- Pipeline validation: Enable required pipeline checks before merge
- Merge strategies: Use squash or no-fast-forward for clean history
Pull Request Workflow
- Automated validation: Let pipelines validate Terraform changes
- Peer review: Have infrastructure team review cost optimizations
- Staging deployment: Test changes in non-production first
- Monitoring: Watch metrics after applying changes
- Documentation: Update runbooks if infrastructure changes
Bitbucket Cloud vs Server
Feature Comparison
| Feature | Bitbucket Cloud | Bitbucket Server |
|---|---|---|
| Authentication | App Password | Personal Access Token |
| Repository Format | workspace/repo-slug | project/repo |
| API Version | REST 2.0 | REST 1.0 |
| Webhooks | Native support | Native support |
| Pipelines | Built-in | Plugin required |
Configuration Differences
Bitbucket Cloud:
- Uses workspace-based permissions
- App passwords have granular scopes
- Automatic HTTPS endpoints
Bitbucket Server:
- Uses project-based permissions
- Requires full server URL
- May need firewall/VPN configuration
Security Considerations
Credential Security
- Jetscale encrypts app passwords and tokens at rest (AES-256)
- Credentials never appear in logs or API responses
- All Bitbucket API calls use HTTPS with TLS 1.2+
- Credentials stored separately with restricted access
Audit Trail
All Jetscale actions are logged:
- Bitbucket API calls
- Pull request creation per recommendation
- Failed authentication attempts
- Repository access events
Audit logs available in Jetscale dashboard under Settings → Audit Log.
Revoking Access
To immediately revoke access:
Bitbucket Cloud:
- Go to App passwords
- Click Revoke next to Jetscale password
Bitbucket Server:
- Navigate to Personal access tokens
- Click Revoke next to Jetscale token
Jetscale:
- Go to Settings → Integrations → Bitbucket
- Click Disconnect
API Reference
For programmatic access, see our API Documentation.
Key endpoints:
POST /api/v1/bitbucket/action/connect- Connect Bitbucket accountPOST /api/v1/bitbucket/action/select-repo- Select repositoryGET /api/v1/bitbucket/repos- List accessible repositoriesPOST /api/v1/bitbucket/action/pr/create- Create pull requestPOST /api/v1/bitbucket/action/disconnect- Disconnect Bitbucket
Support
Need help with Bitbucket integration?
- Email: support@jetscale.ai
- Documentation: FAQ
- GitHub Issues: Report a problem
Slack Integration
Jetscale integrates with Slack to deliver real-time cost optimization notifications directly to your team channels, keeping everyone informed about new recommendations,...
AI-Powered Analysis
How Jetscale's AI generates cost optimization recommendations while maintaining performance and reliability
