Docs
CI/CD Integration
CI/CD Integration
Learn how to integrate CommitStudio with your CI/CD pipelines for automated code reviews
CI/CD Integration
CommitStudio can be seamlessly integrated into your CI/CD pipelines to automate code reviews as part of your development workflow.
Integration Approaches
There are several ways to integrate CommitStudio into CI/CD pipelines:
- Direct integration - Run CommitStudio directly within your pipeline
- GitHub Actions - Use the dedicated GitHub Actions integration
- Custom workflow - Create a custom workflow script that calls CommitStudio
Direct CI/CD Integration
GitLab CI
Here's an example .gitlab-ci.yml
configuration:
stages:
- review
code-review:
stage: review
image: node:18
script:
- npm install -g commitstudio
- commitstudio --path . --no-cache
variables:
GITHUB_TOKEN: ${GITHUB_TOKEN}
OPENAI_API_KEY: ${OPENAI_API_KEY}
only:
- merge_requests
Jenkins
For Jenkins, create a pipeline step:
pipeline {
agent {
docker {
image 'node:18'
}
}
stages {
stage('Code Review') {
steps {
sh 'npm install -g commitstudio'
sh 'commitstudio --path . --no-cache --verbose'
}
environment {
GITHUB_TOKEN = credentials('github-token')
OPENAI_API_KEY = credentials('openai-key')
}
}
}
}
CircleCI
Example .circleci/config.yml
:
version: 2.1
jobs:
code-review:
docker:
- image: cimg/node:18.0.0
steps:
- checkout
- run:
name: Install CommitStudio
command: npm install -g commitstudio
- run:
name: Run CommitStudio
command: commitstudio --path . --no-cache
environment:
GITHUB_TOKEN: ${GITHUB_TOKEN}
OPENAI_API_KEY: ${OPENAI_API_KEY}
workflows:
version: 2
review:
jobs:
- code-review:
filters:
branches:
only: /pull\/.*/
GitHub Actions Integration
For GitHub-specific integrations, we recommend using our GitHub Actions workflow.
Advanced CI/CD Configurations
Custom AI Model Selection
You can specify different AI models for different types of changes:
- name: Run CommitStudio for Security-Critical Code
if: contains(github.event.pull_request.labels.*.name, 'security')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_MODEL: gpt-4o
run: |
commitstudio --path . --branch ${{ github.head_ref }}
- name: Run CommitStudio for Regular Code
if: "!contains(github.event.pull_request.labels.*.name, 'security')"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_MODEL: gpt-4.1-mini
run: |
commitstudio --path . --branch ${{ github.head_ref }}
Running on Specific File Types
To only run on specific file types:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40
- name: Run CommitStudio on JavaScript Files Only
if: steps.changed-files.outputs.any_changed == 'true'
run: |
CHANGED_JS_FILES=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | grep -E '\.js$|\.jsx$|\.ts$|\.tsx$' || echo "")
if [ ! -z "$CHANGED_JS_FILES" ]; then
commitstudio --path . --files "$CHANGED_JS_FILES" --branch ${{ github.head_ref }}
fi
Scheduled Reviews
You can set up scheduled reviews to periodically analyze your codebase:
name: Scheduled Code Review
on:
schedule:
- cron: '0 0 * * 1' # Run every Monday at midnight
jobs:
code-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install CommitStudio
run: npm install -g commitstudio
- name: Run CommitStudio
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
commitstudio --path . --since "7 days ago" --no-cache
Related Topics
- GitHub Actions Integration - Specific details for GitHub Actions
- Configuration Options - Available configuration options
- JavaScript API - Programmatic usage in custom scripts