site/docs/integrations/bitbucket-pipelines.md
This guide demonstrates how to set up promptfoo with Bitbucket Pipelines to run evaluations as part of your CI pipeline.
Create a new file named bitbucket-pipelines.yml in the root of your repository with the following configuration:
image: node:20
pipelines:
default:
- step:
name: Promptfoo Evaluation
caches:
- node
script:
- npm ci
- npm install -g promptfoo
- npx promptfoo eval
artifacts:
- promptfoo-results.json
- promptfoo-results.xml
Store your LLM provider API keys as repository variables in Bitbucket:
OPENAI_API_KEY, ANTHROPIC_API_KEY)You can configure the pipeline to fail when promptfoo assertions don't pass:
script:
- npm ci
- npm install -g promptfoo
- npx promptfoo eval --fail-on-error
Run evaluations with specific configuration files:
script:
- npm ci
- npm install -g promptfoo
- npx promptfoo eval --config custom-config.yaml
Configure different behavior for pull requests:
pipelines:
default:
- step:
name: Promptfoo Evaluation
script:
- npm ci
- npm install -g promptfoo
- npx promptfoo eval
pull-requests:
'**':
- step:
name: Promptfoo PR Evaluation
script:
- npm ci
- npm install -g promptfoo
- npx promptfoo eval --fail-on-error
Run evaluations on a schedule:
pipelines:
default:
- step:
name: Promptfoo Evaluation
script:
- npm ci
- npm install -g promptfoo
- npx promptfoo eval
custom:
nightly-evaluation:
- step:
name: Nightly Evaluation
script:
- npm ci
- npm install -g promptfoo
- npx promptfoo eval
schedules:
- cron: '0 0 * * *' # Run at midnight UTC every day
pipeline: custom.nightly-evaluation
branches:
include:
- main
Test across multiple configurations in parallel:
image: node:20
pipelines:
default:
- parallel:
- step:
name: Evaluate with GPT-4
script:
- npm ci
- npm install -g promptfoo
- npx promptfoo eval --providers.0.config.model=gpt-4
artifacts:
- promptfoo-results-gpt4.json
- step:
name: Evaluate with Claude
script:
- npm ci
- npm install -g promptfoo
- npx promptfoo eval --providers.0.config.model=claude-3-opus-20240229
artifacts:
- promptfoo-results-claude.json
Leverage Bitbucket Pipes for a more concise configuration:
image: node:20
pipelines:
default:
- step:
name: Promptfoo Evaluation
script:
- npm ci
- npm install -g promptfoo
- npx promptfoo eval
after-script:
- pipe: atlassian/junit-report:0.3.0
variables:
REPORT_PATHS: 'promptfoo-results.xml'
If you encounter issues with your Bitbucket Pipelines integration: