This component is a Docker-based code review pipeline to provide automated code reviews using either OpenAI's GPT or Google's Gemini AI models. It's adapted from the Bitbucket Pipeline for ChatGPT code reviews.
- Automated code review for pull requests
- Support for multiple AI providers:
- OpenAI GPT models
- Google Gemini
- Customizable review focus through file filtering
- Token limit management
- Detailed logging
- JSON-formatted review comments
- Bitbucket API integration
- Bitbucket repository access
- AI Provider API key (OpenAI or Google)
- Docker
BITBUCKET_PR_ID
: Pull request ID (automatically set in PR builds)BITBUCKET_WORKSPACE
: Your Bitbucket workspace nameBITBUCKET_REPO_SLUG
: Your repository slug
BITBUCKET_ACCESS_TOKEN
: Bitbucket access token- OR
BITBUCKET_USERNAME
: Bitbucket usernameBITBUCKET_APP_PASSWORD
: Bitbucket app password
OPENAI_API_KEY
: Your OpenAI API keyOPENAI_BASE_URL
: API base URL (can be modified for Gemini)MODEL
: AI model to useORGANIZATION
: (Optional) Organization IDCHATGPT_PROMPT_MAX_TOKENS
: Maximum tokens limit (defaults to 0 if not set)
MESSAGE
: Custom system message for the AIFILES_TO_REVIEW
: Comma-separated list of files to reviewCHATGPT_COMPLETION_FILEPATH
: Path to YAML file with completion parametersCHATGPT_CLIENT_FILEPATH
: Path to YAML file with client parameters
The pipeline includes error handling for:
- Missing authentication
- Token limit exceeded
- Invalid YAML configurations
- API errors
- JSON parsing errors
Detailed logging is available for:
- Configuration details
- Processing time
- Token usage
- Files reviewed
- Number of suggestions
docker build -t ai-code-reviewer .
docker run ai-code-reviewer