Bitbucket Pipelines Integration
Overview#
This integration allows Bitbucket Pipelines to automatically notify Lathe Studio when builds complete, creating builds that can be assigned to releases for testing.
Setup#
1. Create an API Key
- Go to Settings > Organization > API Keys
- Click Create API Key
- Give it a name (e.g., "Bitbucket Pipelines")
- Select scopes:
builds:read- View buildsbuilds:create- Create new builds
- Copy the generated key (shown only once)
2. Configure Bitbucket Webhook
- In Bitbucket, go to your repository
- Navigate to Repository settings > Webhooks
- Click Add webhook
- Configure:
- Title: Lathe Studio
- URL:
https://your-app.com/api/webhooks/bitbucket - Triggers: Select "Pipeline events"
- Active: Check this box
- Optionally add headers:
Authorization: Bearer <your-api-key>(if using API key auth)X-Pt-Org-Id: <your-org-id>(if using org ID auth)
3. Test the Integration
- Trigger a pipeline in Bitbucket
- Go to Releases page in Lathe Studio
- You should see the build in the Build Queue section
- Assign it to a release
Authentication Methods#
Method 1: API Key (Recommended)
Include the API key in the Authorization header:
Authorization: Bearer pt_live_xxxxxxxxxxxxxxxx
Benefits:
- Rate limiting per key
- Usage tracking
- Scoped permissions
Method 2: Organization ID
Include your organization ID in a custom header:
X-Pt-Org-Id: your-org-uuid
Note: This method has basic rate limiting and is less secure. Use API keys for production.
How It Works#
- Pipeline Completes → Bitbucket sends webhook to
/api/webhooks/bitbucket - Authentication → Webhook verifies API key or org ID
- Project Matching → System tries to match repo URL to a project
- Queue or Create:
- If project + active release found → Build created directly
- If project found but no release → Queued for release assignment
- If no project match → Queued for project + release assignment
- Assignment → User assigns queued builds via Releases page
Build Queue UI#
The Build Queue appears on the Releases page when there are pending builds:
- Shows build name, source (Bitbucket/GitHub/etc), project, commit/branch
- Assign to Release: Select an active release for the project
- Select Project: Navigate to projects if project not auto-detected
- Reject: Remove build from queue (no build created)
Troubleshooting#
Builds not appearing
- Check webhook delivery in Bitbucket (Repository settings > Webhooks > View requests)
- Verify API key is not expired or revoked
- Check that the pipeline event is being sent
Wrong project assigned
The system matches by:
- Repository URL (exact match)
- Repository name (partial match)
You can manually assign to the correct project from the queue.
Rate limiting
API keys are limited to 60 requests per minute by default. Contact support to increase limits.
API Reference#
Direct API Usage
You can also create builds directly via the REST API:
curl -X POST https://your-app.com/api/v1/builds \
-H "Authorization: Bearer <api-key>" \
-H "Content-Type: application/json" \
-d '{
"name": "Build #123",
"build_number": "123",
"commit_sha": "abc123...",
"branch": "main",
"repo_url": "https://bitbucket.org/org/repo"
}'
Response:
201 Created- Build created with release202 Accepted- Build queued for manual assignment401 Unauthorized- Invalid API key429 Too Many Requests- Rate limit exceeded
Security#
- API keys are hashed using SHA-256 before storage
- Only the first 12 characters are stored for identification
- Keys can be revoked at any time
- Webhook signatures (HMAC) support planned for future releases