GitLab CI
Overview
Prerequisites
Quick Setup
1
Variable
Value
Options
2
stages:
- review
tabnine-code-review:
stage: review
image: node:20
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
variables:
TABNINE_HOST: "https://console.tabnine.com"
TABNINE_MODEL_ID: ""
before_script:
# Input validation
- |
if [ -z "$TABNINE_KEY" ]; then
echo "Error: TABNINE_KEY not set"
exit 1
fi
if [ -z "$GITLAB_API_TOKEN" ]; then
echo "Error: GITLAB_API_TOKEN not set"
exit 1
fi
- 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"
if [ ! -f ~/.local/bin/tabnine ]; then
echo "Error: Tabnine CLI installation failed"
exit 1
fi
# Configure git
- git config user.name "Tabnine CLI Agent"
- git config user.email "[email protected]"
# Configure Tabnine Auth & Settings
- |
mkdir -p ~/.tabnine/agent
MODEL_BLOCK=""
if [ -n "$TABNINE_MODEL_ID" ]; then
MODEL_BLOCK=",\"model\":{\"name\":\"$TABNINE_MODEL_ID\"}"
fi
cat << EOF > ~/.tabnine/agent/settings.json
{
"general": { "tabnineHost": "$TABNINE_HOST" },
"security": { "auth": { "selectedType": "tabnine-personal" } }${MODEL_BLOCK}
}
EOF
chmod 600 ~/.tabnine/agent/settings.json
script:
# The agent reviews the MR diff and posts comments
- TABNINE_TOKEN=$TABNINE_KEY ~/.local/bin/tabnine -y -p "<REVIEW_PROMPT>"
allow_failure: true3
Configuration
Required CI/CD Variables
Variable
Description
Optional CI/CD Variables
Variable
Default
Description
GitLab API Token
1
2
3
4
How It Works
1
2
3
4
5
Important Notes
Customization
Using a Specific Model
Self-Hosted / EMT Installations
Troubleshooting
See Also
Last updated
Was this helpful?
