Bitbucket Cloud Setup
Pipelines as Code supports Bitbucket Cloud through webhooks, enabling CI/CD automation for your Bitbucket repositories.Prerequisites
Before starting, ensure you have installed Pipelines as Code on your Kubernetes cluster.Create Bitbucket API Token
Bitbucket Cloud uses App Passwords for API authentication.Navigate to App Passwords
Follow Atlassian’s guide to create an App Password.Go to: Personal settings > App passwords > Create app password
Configure permissions
Select these permissions for the App Password:
account:read- Read your account informationrepository:read- Read repository content and metadatarepository:write- Write to repositories (for setting commit status)pullrequest:read- Read pull request informationpullrequest:write- Write to pull requests (for comments)webhook:read- Read webhook configurations (if using CLI setup)webhook:write- Manage webhooks (if using CLI setup)
- workspace:read
- repository:read
- repository:write
- pullrequest:read
Create Repository and Configure Webhook
There are two methods to set up your Repository and webhook:Automated Setup with tkn pac CLI
Manual Setup
Create webhook in Bitbucket
- Navigate to your Bitbucket Cloud repository
- Go to Repository settings > Webhooks
- Click Add webhook
-
Configure:
- Title:
Pipelines-as-Code - URL: Your Pipelines as Code controller URL
- Status: Active (checked)
- Title:
-
Select these triggers:
Repository events:
- Push
- Updated
- Commit comment created
- Created
- Updated
- Merged
- Declined
- Comment created
- Comment updated
- Click Save
Security Model
Adding Additional IP Addresses
If you need to allow webhooks from additional IPs or networks (e.g., for proxies):-
Edit the
pipelines-as-codeConfigMap: -
Add the
bitbucket-cloud-additional-source-ipkey:You can specify multiple networks or IPs separated by commas.
Disabling IP Validation
If you must disable IP validation:Managing Webhooks and Tokens
Add Webhook to Existing Repository
Update App Password
When you need to rotate your App Password:Using tkn pac CLI
Using kubectl
Find the secret name in your Repository CRD:Important Notes
- User identification: Must use Atlassian email address in
git_provider.userfield - Account ID in OWNERS: Reference users by
ACCOUNT_IDin OWNERS files (see GDPR changes) - No webhook secrets: Security relies on IP address validation
- Secrets scope: Secrets must be in the same namespace as Repository CRD
- Bootstrap not supported:
tkn pac bootstrapcommand is not available for Bitbucket Cloud
Troubleshooting
Webhooks Not Being Received
-
Check IP validation:
Look for IP validation errors.
-
Verify webhook configuration:
- Go to Repository settings > Webhooks
- Check the webhook’s Recent Deliveries
- Look for failed requests or error responses
- Test webhook manually: Click “Test connection” in the webhook settings to trigger a test event.
Pipeline Not Triggering on Pull Requests
Ensure these pull request events are selected:- Created
- Updated
- Comment created
Authentication Failures
Verify:- App Password has correct permissions
- Using Atlassian email address (not username) in Repository CRD
- Secret exists in correct namespace
Next Steps
After configuring Bitbucket Cloud:- Add
.tektondirectory with pipeline definitions to your repository - Test by creating a pull request or pushing commits
- Monitor pipeline status in pull request comments