Bitbucket Pipelines
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.
Prerequisites
A Bitbucket repository with Pipelines enabled
A Tabnine account with Agents enabled
TABNINE_KEY- Tabnine Personal access tokenBB_API_TOKEN- A Bitbucket access token withpullrequest:writeandrepository:readscopes
Quick Setup
Add repository variables
Go to your repository's Repository Settings > Pipelines > Repository variables and add:
TABNINE_KEY
Tabnine Personal Access Token
✅ Secured
BB_API_TOKEN
Bitbucket access token
✅ Secured
Add the pipeline configuration
Copy the bitbucket-pipelines.yml from the tabnine-pr-agent repository to the root of your Bitbucket repository.
If you already have a bitbucket-pipelines.yml, merge the pull-requests section into your existing configuration:
image: node:22.23.4
pipelines:
pull-requests:
'**':
- step:
name: Tabnine Code Review
script:
- export TABNINE_HOST="${TABNINE_HOST:-https://console.tabnine.com}"
- export TABNINE_MODEL_ID="${TABNINE_MODEL_ID:-}"
# Input validation
- |
if [ -z "$TABNINE_KEY" ]; then
echo "Error: TABNINE_KEY not set"
exit 1
fi
if [ -z "$BB_API_TOKEN" ]; then
echo "Error: BB_API_TOKEN not set"
exit 1
fi
# Install dependencies
- apt-get update -qq && apt-get install -y -qq curl git jq > /dev/null 2>&1
# Install Tabnine CLI
- |
curl -fsSL "$TABNINE_HOST/update/cli/installer.mjs" -o installer.mjs
node installer.mjs "$TABNINE_HOST"
# Configure and run review
# ... (see full configuration link below)See the full configuration for the complete pipeline including authentication setup and the review prompt.
Open a pull request
Push the configuration and open a PR. The Tabnine Code Review will run automatically.
Configuration
Required Repository Variables
TABNINE_KEY
Tabnine authentication credentials (PAT). Mark as Secured.
BB_API_TOKEN
Bitbucket access token with pullrequest:write and repository:read scopes. Mark as Secured.
Optional Repository Variables
TABNINE_HOST
https://console.tabnine.com
Tabnine host URL (for self-hosted / Private installations)
TABNINE_MODEL_ID
—
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:
Go to Repository Settings > Access tokens (repository-level) or your Personal Settings > App passwords (account-level)
Create a token with pullrequest:write and repository:read scopes
Add it as a repository variable named BB_API_TOKEN and mark it as Secured
How It Works
Validate inputs
Checks that TABNINE_KEY and BB_API_TOKEN are set.
Install dependencies
Installs Tabnine CLI and required tools (curl, git, jq).
Configure authentication and settings
Sets up authentication and any pipeline-specific environment variables.
Resolve destination commit SHA
Uses the Bitbucket API to resolve the destination branch commit SHA.
Clean up previous comments
Removes previous Tabnine PR Bot comments from the PR.
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 slugBITBUCKET_REPO_SLUG— Repository slugBITBUCKET_PR_ID— Pull request IDBITBUCKET_COMMIT— Head commit SHABITBUCKET_PR_DESTINATION_BRANCH— Destination branch name
Important Notes
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 / Private Installations
Set the TABNINE_HOST repository variable, or override it in the pipeline script:
Troubleshooting
See Also
Git Integrations Overview — Supported platforms and review capabilities
GitHub Actions — Setup for GitHub
GitLab CI/CD — Setup for GitLab
Last updated
Was this helpful?
