Bitbucket Data Center Setup
Pipelines as Code has full support for Bitbucket Data Center (formerly Bitbucket Server), enabling CI/CD automation for on-premises Bitbucket installations.Prerequisites
Before starting, ensure you have installed Pipelines as Code on your Kubernetes cluster.Create Personal Access Token
Create a personal access token for Pipelines as Code to interact with Bitbucket Data Center.Navigate to token settings
Follow Atlassian’s guide: https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html
- Click your profile icon in Bitbucket
- Go to Manage account > Personal access tokens
- Click Create a token
Configure token permissions
The token needs these permissions:
- PROJECT_ADMIN - For project-level operations
- REPOSITORY_ADMIN - For repository management and webhook configuration
The token needs access to forked repositories when processing pull requests from forks. Ensure the token owner has appropriate permissions.
Configure Webhook
Generate webhook secret
Generate a secure random secret:Save this value for both webhook configuration and Kubernetes secret creation.
Get controller URL
On OpenShift:For other Kubernetes distributions, get the ingress URL for the Pipelines as Code controller service.
Create webhook in Bitbucket
Follow Atlassian’s webhook guide:
- Navigate to your repository in Bitbucket Data Center
- Go to Repository settings > Webhooks
- Click Create webhook
-
Configure:
- Name:
Pipelines-as-Code - URL: Your Pipelines as Code controller URL
- Secret: The secret you generated above
- Status: Active (enabled)
- Name:
-
Select these events:
Repository events:
- Push
- Modified
- Opened
- Source branch updated
- Comments added
- Click Create
Create Repository CRD
Create Repository CRD
Important URL Configuration
spec.url: The Git clone URL of your repositoryspec.git_provider.url: The base URL of your Bitbucket Data Center instance (without/restsuffix)spec.git_provider.user: Your Bitbucket username
Configuration Examples
Standard Configuration
With Custom Secret Keys
Managing Tokens
Update Personal Access Token
When your token expires or needs rotation:Using kubectl
Find the secret name in your Repository CRD:By Recreating the Secret
Important Notes
- Secrets scope: Secrets cannot reference secrets in other namespaces. They must be in the same namespace as the Repository CRD
- CLI support:
tkn pac createandtkn pac bootstrapcommands are not supported for Bitbucket Data Center - User identification: Reference users by
ACCOUNT_IDin OWNERS files, not by username - Licensed users: Service accounts need licensed user status for group-based permissions
- API URL format: Do not include
/restsuffix ingit_provider.url
Troubleshooting
Webhooks Not Being Received
-
Check webhook delivery:
- Go to Repository settings > Webhooks in Bitbucket
- View webhook delivery history
- Check for failed requests or error responses
-
Verify controller logs:
- Test webhook manually: Click the webhook’s test button in Bitbucket settings.
Authentication Failures
Verify:- Token has
PROJECT_ADMINandREPOSITORY_ADMINpermissions - Token owner is a licensed Bitbucket user
- Username in Repository CRD matches token owner
- Secret exists in the correct namespace
API URL Issues
Pipelines as Code automatically appends the API path.SSL Certificate Errors
For self-signed certificates, see the certificate configuration documentation.Permission Errors for Fork Pull Requests
Ensure:- Token owner has access to both source and target repositories
- Service account is a licensed user
- Users have direct permissions (not just group-based) if service account is unlicensed
Next Steps
After configuring Bitbucket Data Center:- Add
.tektondirectory with pipeline definitions to your repository - Test by creating a pull request or pushing commits
- Monitor pipeline status in pull request comments and build status