Run Tabnine CLI on every Bitbucket pull request to automate code review, documentation, test generation, and more.
Overview
The Tabnine Bitbucket Pipeline step runs the Tabnine CLI Agent on pull request events. The included configuration provides a comprehensive code review prompt that analyzes the PR diff and posts a summary comment and inline comments directly on the pull request using the Bitbucket API. You can customize the prompt to automate any task — see Customizing the Prompt.
Model ID for the AI agent. If empty, uses the system default from the admin console.
Bitbucket Access Token
The BB_API_TOKEN is used by the agent to interact with the Bitbucket REST API — fetching PR details, reading diffs, and posting comments.
Creating an access token:
1
Go to Repository Settings > Access tokens (repository-level) or your Personal Settings > App passwords (account-level)
2
Create a token with pullrequest:write and repository:read scopes
3
Add it as a repository variable named BB_API_TOKEN and mark it as Secured
Repository access tokens are preferred over personal app passwords for CI/CD use, as they are scoped to a single repository.
How It Works
1
Validate inputs
Checks that TABNINE_KEY and BB_API_TOKEN are set.
2
Install dependencies
Installs Tabnine CLI and required tools (curl, git, jq).
3
Configure authentication and settings
Sets up authentication and any pipeline-specific environment variables.
4
Resolve destination commit SHA
Uses the Bitbucket API to resolve the destination branch commit SHA.
5
Clean up previous comments
Removes previous Tabnine PR Bot comments from the PR.
6
Run the review
Fetches the PR diff via the Bitbucket API (api.bitbucket.org/2.0), analyzes the code, and posts summary and inline comments.
The pipeline uses these Bitbucket predefined variables automatically:
BITBUCKET_WORKSPACE — Workspace slug
BITBUCKET_REPO_SLUG — Repository slug
BITBUCKET_PR_ID — Pull request ID
BITBUCKET_COMMIT — Head commit SHA
BITBUCKET_PR_DESTINATION_BRANCH — Destination branch name
Important Notes
The '**' glob pattern in the pull-requests section means the review runs on PRs targeting any branch. Adjust the pattern to limit which branches trigger reviews (e.g., 'main' or 'develop').
Unlike GitHub Actions, Bitbucket Pipelines does not have a built-in continue-on-error equivalent at the step level. The pipeline step will fail if the review encounters an error. Consider wrapping the review command in a script that always exits 0 if you want advisory-only behavior.
Customization
Reviewing Only Specific Branches
Change the glob pattern to match only PRs targeting specific branches:
Using a Specific Model
Set the TABNINE_MODEL_ID repository variable, or set a default directly in the pipeline:
Self-Hosted / EMT Installations
Set the TABNINE_HOST repository variable, or override it in the pipeline script:
Troubleshooting
"Error: TABNINE_KEY not set"
The repository variable is missing or empty.
Solution: Add TABNINE_KEY in Repository Settings > Pipelines > Repository variables. Mark it as Secured.
"Error: BB_API_TOKEN not set"
The repository variable is missing or empty.
Solution: Create a Bitbucket access token with pullrequest:write and repository:read scopes and add it as a repository variable named BB_API_TOKEN.
Pipeline does not run on pull requests
Possible causes:
Pipelines are not enabled for the repository — go to Repository Settings > Pipelines > Settings and enable them
The pull-requests section is missing or misconfigured in bitbucket-pipelines.yml
The PR target branch does not match the glob pattern
No comments appear on the PR
Possible causes:
The BB_API_TOKEN lacks pullrequest:write scope
The PR diff is empty or contains only low-risk changes