Running promptfoo in Bitbucket Pipelines

Running promptfoo in Bitbucket Pipelines gives a repository repeatable LLM eval and red team runs on each change. This page covers the step, key handling, artifacts and the checks that close each stage.

On this page

How promptfoo runs inside a Bitbucket Pipelines step

A team that keeps prompts, model settings or application logic in a Bitbucket repository needs promptfoo evals or red team scans to run on each change, before a merge reaches the main branch. The documented Bitbucket Pipelines example for promptfoo uses the node:24 image as the build environment, installs promptfoo inside the step, runs it against the model providers the team has configured, and reads LLM provider keys from Bitbucket repository variables rather than from the YAML file. Your first decision is which pipeline events should trigger the step, for example pull requests or a branch pattern, because each trigger adds model calls and therefore spend. Confirm the exact pipeline syntax and image tag against the current promptfoo Bitbucket documentation before you copy it, since the example is the starting point, not a guarantee for your repository.

promptfoo runs locally inside the build container. Evals execute on the Bitbucket runner, and the tool sends requests directly from that runner to the model providers you configure. No promptfoo-hosted service sits in the middle of that traffic, which matters for security reviewers who need to know where prompts, outputs and provider credentials travel. The tool is released under the MIT license, so your legal team can review the license terms in the repository alongside the rest of your dependencies. Ask the team to list every provider endpoint the step can reach and to confirm that the network policy of your Bitbucket workspace or self-hosted runners allows those outbound calls.

Plan for what the step leaves behind. Prompts, test inputs and model outputs can appear in logs and report files, and Bitbucket keeps step output and artifacts according to settings your workspace administrators control. Before the first run, confirm who can read pipeline logs in the repository, who can download artifacts, and whether masked repository variables hide provider keys in the log output. Write the retention and access answers into the team's review notes, because they determine what a red team report can safely contain and who should see it.

What the Bitbucket step needs before the first run

The Bitbucket step is only as ready as the repository, config and accounts behind it. Each item below is a decision or check to settle before the first pipeline run, so failures in CI reflect prompt or model changes rather than setup gaps.

A repository with Pipelines enabled

Confirm that the Bitbucket repository has Pipelines turned on and that a bitbucket-pipelines.yml file sits at the root of the default branch. Check who can edit that file, since a change to the pipeline can change what runs against your provider accounts. Decide early whether pull request pipelines should run the full suite or a smaller subset, because that choice drives both time and API spend.

Bitbucket Pipelines docs

A promptfoo config and test suite

The step needs a committed promptfoo configuration that names the prompts, providers and test cases under evaluation. Keep the config and datasets in the repository so every run is traceable to a commit. Run the suite locally once before wiring it into CI, which confirms the file paths and assertions work outside the pipeline.

Provider accounts and usage limits

Identify every model provider the suite calls and the account that owns each key. Confirm the spend limits, rate limits and project scopes on each account before the first run, since a misconfigured matrix or large red team scan can consume a budget quickly. Ask whether each key can be restricted to evaluation use only.

Node.js 22.22.0 or newer

The current npm release of promptfoo, 0.124.1, requires Node.js 22.22.0 or newer. The node:24 image used in the example meets that requirement. Pin the promptfoo version in your step rather than installing the latest release, and confirm the version against the npm registry and promptfoo releases on GitHub before you commit it.

promptfoo on npm

Repository variables for provider keys

Create each provider key as a secured repository variable in Bitbucket, not as a plain value in bitbucket-pipelines.yml. Mark secret variables so they are masked in logs, and confirm which workspace or repository roles can read or change them. Rotate keys on a schedule and record who holds access to the repository settings.

Ownership of reports and retention

Decide where reviewers will look for results before the first run, and who is responsible for them. Reports can contain prompts, model outputs and sample data, so check what the artifacts include and who can download them. Confirm the artifact retention period in your Bitbucket settings rather than assuming a default.

Configure the bitbucket-pipelines.yml step in order

This sequence takes a repository from no promptfoo setup to a pipeline that runs an eval on the node:24 image, keeps provider keys out of the YAML and leaves a report file that reviewers can open from the run. Each step ends with a check so a failure is found where it starts.

  1. Add provider keys as secured repository variables

    In the Bitbucket repository settings, open the repository variables area and add each LLM provider key the eval calls, such as the key your model platform issues. Mark each variable as secured so its value is masked in logs and cannot be read back in the UI after saving. Confirm the variable exists by checking its name in the list, and never print the value in a debug step or a commit. Ask your security team whether repository variables or deployment variables meet your key handling policy, since that decision sets who can read the keys.

  2. Confirm the variables reach the pipeline without printing them

    Before any eval runs, add a short test step that checks whether each variable is set, for example by testing that the variable is non-empty and printing only a yes or no result. The check proves the variable name matches what the eval config expects. If the check prints the value, remove it and rotate the key, because a printed value may already be stored in build history.

  3. Create bitbucket-pipelines.yml on the node:24 image

    Add a bitbucket-pipelines.yml file at the repository root that sets the default image to node:24 and defines one step for promptfoo. Keep the step on a branch or pull request trigger that matches your review process. The step is done when the pipeline starts on a commit and Bitbucket shows the node:24 image in the step log, which confirms the runner has Node.js available before promptfoo is installed.

  4. Install promptfoo in the step

    Add a script line that installs the promptfoo package with npm, pinned to the version your team has tested. The npm release 0.124.1 requires Node.js 22.22.0 or newer, so the node:24 image satisfies that requirement. Check that the install output ends without errors and that the step prints the installed version, which you should record so later upgrades can be compared against it.

  5. Run the eval against the repository config

    Add a script line that runs the promptfoo eval command against the configuration file committed in the repository, so the test cases and assertions are reviewed like any other code. Write the output to a fixed directory such as a reports folder under the build directory, and set the step to fail when the command exits with an error. Before relying on the step in a gate, run the same command on your own machine with the same config and confirm the results match.

  6. Save reports as pipeline artifacts

    Declare the reports directory as an artifact in the step so Bitbucket keeps the files after the run finishes. Use a path that does not overlap with source files. The step is complete when a pipeline run finishes and the artifact list contains the report file, which reviewers can download and open. Check that the file contains no secrets before sharing it widely, since eval output can echo prompts and responses.

  7. Review the first run and tighten the configuration

    Open the first pipeline run, confirm the key check passed, the install step recorded the version, the eval exited as expected and the report artifact downloads. Then decide whether the step should block merges or only report results while your team tunes the test cases. Record the decision and the reasons in the repository documentation so the next change to the pipeline has a clear owner and history.

How the pipeline, repository variables, model providers and reports connect

The flow starts when a commit or pull request triggers a Bitbucket pipeline, which runs a step on the node:24 image and installs promptfoo. The step reads LLM provider keys from repository variables, so the keys are injected at run time rather than written into bitbucket-pipelines.yml. promptfoo then sends requests directly to the model provider endpoints under test, and the report files are saved as pipeline artifacts for reviewers. Check where the trust boundary sits: the keys and prompts leave Bitbucket-managed storage for the provider endpoints, and your provider terms govern that hop.

Data flow from a pull request to provider endpoints and stored reports, with the Bitbucket boundary marked.

Which values go in repository variables and which stay in the config

This table maps each value the promptfoo step uses to where it should live, who can read it, and what must stay out of build logs. Read it as a checklist before you commit the pipeline file, since a single key printed by a debug command can expose a provider account. Confirm Bitbucket's variable scope and secured-variable options for your workspace before relying on them.

ValueWhere it livesWho can read itKeep out of build logs
Provider API keys (for example, OpenAI or Anthropic keys)Secured Bitbucket repository variables, referenced by name in the stepUsers with repository admin or variable-edit permission, plus pipeline steps that run in the repositoryThe key value itself, and any command that echoes the environment or prints the config with expanded variables
Model names and provider endpointspromptfooconfig.yaml or other config file committed to the repositoryAnyone with read access to the repositoryNothing sensitive, unless an endpoint embeds a token, in which case move the token into a variable
Prompts and test datasetsRepository files such as prompt templates and CSV or YAML test casesAnyone with read access to the repositoryCustomer or production data copied into test cases, which should be reviewed before commit
Red team configuration and plugin settingsRepository config file reviewed alongside promptsAnyone with read access to the repositoryGenerated attack output that quotes sensitive content from the target application
Eval and red team reports (JSON, HTML, JUnit XML)Pipeline artifacts attached to the run, retained for the period set in your workspaceUsers who can view the pipeline run and download artifactsRaw model responses that may contain personal or confidential data, so confirm retention before enabling artifacts
Optional provider or gateway base URLs with credentialsSecured repository variablesSame audience as provider API keysThe full URL when it contains credentials or internal hostnames

Hardening the step that holds provider keys

The Bitbucket step is only as safe as the secrets, permissions and stored output around it. The cards below cover the controls that protect provider keys during a promptfoo run, and the review habits that keep eval reports from leaking more than intended.

Store keys as secured repository variables

Keep every LLM provider key in a Bitbucket repository variable marked as secured, so its value is masked in logs and is not shown again in the Bitbucket interface after it is saved. Reference the variable by name in the bitbucket-pipelines.yml step and never place the value in the YAML, a .env file or a promptfoo config committed to the repository. Check that the variable is not available to forks or to pipelines on untrusted branches before the first run.

promptfoo Bitbucket docs

Issue least-privilege keys with spend limits

Create a separate provider key for CI, scoped to only the models the eval suite calls, and set a monthly spend limit on it where the provider offers one. A leaked CI key then cannot reach production workloads or unrelated projects. Ask your provider which key types support model restrictions and budget alerts, because the options differ by vendor and plan.

Restrict who can change pipeline and variables

Anyone who can edit bitbucket-pipelines.yml on a branch that runs in the pipeline can print a secured variable by adding a command. Limit repository admin rights to a small group, require pull request review for changes to the pipeline file, and confirm which users can view or edit deployment and repository variables. Review these permissions whenever team membership changes.

Keep secrets out of commands and logs

Avoid echo, printenv, set -x and debug flags in the step, because they can write provider keys into the build log even when variables are secured. Pass keys only through the environment that promptfoo reads, and do not interpolate them into a URL or a command-line argument where shell history and process listings can expose them. Scan the build log after a test run with a deliberately fake key to confirm masking works in your workspace.

Review artifacts before wider sharing

Reports saved as artifacts can contain full prompts, retrieved documents, model outputs and sometimes data from the test cases. Set a short artifact retention period in the pipeline, restrict who can download artifacts, and decide which fields your team is willing to keep. Treat any report that includes customer records or internal documents as sensitive data with the same access rules as the source.

Pin the promptfoo version

Install a specific promptfoo release in the step, such as an exact npm version, instead of the latest tag, so that a new release does not change assertions or grading between builds. Upgrade deliberately, rerun the suite on the new version, and compare results with the previous baseline. Community edition runs locally in the build container, so the pipeline does not need a shared promptfoo server to run safely.

Why stored reports need the same care as the code

Treat promptfoo output files as sensitive records, because an eval or red team report stores the prompts, test inputs and model responses that ran. If the test set was built from real customer conversations, support tickets or internal documents, the artifact can expose that content to anyone who can open the pipeline. Before you add an artifacts section to bitbucket-pipelines.yml, decide which files it needs to keep. A summary such as a pass-rate file is often enough for a merge decision, while full JSON or HTML output carries every response and should be retained only as long as a reviewer needs it.

Set retention and access deliberately. Confirm in your own Bitbucket plan and workspace how long pipeline artifacts are kept and who can download them, including whether repository read access alone grants download rights and whether forks or external collaborators can reach pipeline output. Check whether your workspace restricts who can view pipeline logs, since promptfoo may print prompt or response snippets there too. Ask your security team whether the report contents fall under an existing data classification, and align the retention period and access list with it rather than with the default.

Reviewers should use the stored report to approve a change, not to look for proof that nothing is wrong. Name the reviewer group that signs off on prompt changes, state which report file they check, and record the approval in the pull request. Keep test data for reviews synthetic or redacted wherever possible, so the artifact stays useful without copying live data into a place with broader access. Test this with one pipeline run before you rely on it, and confirm that deleting an artifact also removes the copy you intended to remove.

Choosing when the step runs for each branch type

This is the gate. A pull request into main is the last point where a prompt, model setting or retrieval change can be stopped before it reaches production, so the step here should run the full eval suite that your team considers release-blocking. The cost is the heaviest of the three situations, because every update to an open pull request reruns the suite and each run calls the model provider and any model-graded judge. The reliability risk is that model-graded checks vary between runs, which can block merges for reasons unrelated to the change.

  • Full suite: Run the complete eval set that covers the behavior the change could affect, not a sample.
  • Pass-rate threshold: Decide in advance whether a failing case blocks the merge or only a set percentage of failures does.
  • Cache reuse: A persisted cache lowers repeat cost on reruns, but confirm how the cache is restored in your pipeline setup.
  • Concurrency: Limit parallel calls so provider rate limits do not turn into false failures.
  • Trigger syntax: Confirm the pull request trigger syntax for your Bitbucket plan in Bitbucket's documentation before relying on it.

Check that the pull request trigger fires for the destination branch you intend, and that a failed step blocks merging in your branch permission settings.

Where the first Bitbucket run usually breaks

This table lists the failures that most often stop the first promptfoo run in Bitbucket Pipelines, with the likely cause and the fix for each. Read it before the first run, and again if a step fails with an authentication, install, artifact or exit code error.

FailureLikely causeFix
Provider authentication errorsRepository variable is missing, misnamed, or not exposed to the step, so the LLM provider receives an empty keyConfirm the variable name matches the key the provider config reads, check it is set at repository scope, and mask it so the value never prints in logs
Node version too old for promptfooPipeline image or pinned Node runtime is below the minimum required by the promptfoo release you installUse the node:24 image in the pipeline, print the Node version in the first step, and check the minimum in the promptfoo release notes before upgrading the pin
npm install failsBitbucket build runner cannot reach the npm registry, or a corporate proxy or registry policy blocks the packageCheck network access from the runner, configure the npm registry or proxy the organization approves, and pin the promptfoo version so installs are repeatable
Report missing from artifactsThe output path written by promptfoo does not match the path listed under artifacts in the pipeline fileWrite output to a fixed relative path, such as a reports directory, and use the same path in the artifacts section; confirm the file exists in the step log
Timeouts or rate limit errors from the providerToo many concurrent requests or long suites exceed the provider's rate limits or the step's time allowanceReduce concurrency in the config, add retries with backoff, and split large suites; confirm the provider's current limits with the provider
Build fails on model-graded checksA single flaky judge response or borderline score makes promptfoo exit non-zero and fails the buildSet a pass-rate threshold agreed with the team, review failing cases in the report, and keep deterministic checks as the hard gate

Questions teams ask before running promptfoo in Bitbucket

Is promptfoo free to run in Bitbucket Pipelines?

Yes, the promptfoo software is licensed under the MIT license, and the Community edition is free and includes all LLM evaluation features, all model providers and integrations, and red teaming with 10k probes per month. The costs that remain are the ones outside the tool: your Bitbucket minutes for pipeline runs, and the fees your model providers charge for every request an eval or red team scan makes. Those provider fees recur on every pipeline run, so the number of suites, the number of providers, and how often the pipeline runs are the main levers. Ask your model provider for its billing terms before you schedule runs on every commit.

What drives the effort of a promptfoo Bitbucket setup?

Effort rises with the number of eval suites, the number of model providers under test, the complexity of the pipeline, and the review process that results must pass. A single config running one provider against one suite is a small change to a bitbucket-pipelines.yml file. Effort grows when you add several providers, separate pull request and branch pipelines, pass-rate gates, or a sign-off step before merge. Ask any partner to break its quote into these pieces so you can see which ones your team already covers.

How long does a first working promptfoo step take in Bitbucket?

The duration depends on how many suites and providers the first step covers, how quickly the provider keys and access are available, and whether the team already has a working Node.js job in Bitbucket. A first step that runs one suite on the node:24 image and stores reports as artifacts is the smallest useful version, and it is the part that usually goes fastest. Delays tend to come from waiting for key approval, agreeing on which tests gate a merge, and sorting out failing runs caused by rate limits or cost. Confirm a time estimate against your own repository and provider access before you plan a release.

What does our internal team need to provide for this work?

Your team needs to provide write access to the repository and its Bitbucket repository variables, the LLM provider keys with the permissions the evals require, and named owners for the test data and prompts. Someone must also decide which results block a merge and who reviews the artifacts. Without those owners, the pipeline runs but nobody acts on its output. If a partner runs the work, ask for this list in writing so responsibilities are clear before the first run.

Can our engineers set up promptfoo in Bitbucket without outside help?

Yes, a simple step is a reasonable first project for an engineer who already knows Bitbucket Pipelines and Node.js. The promptfoo documentation for Bitbucket Pipelines gives a working starting point that uses the node:24 image and stores LLM provider keys as repository variables. Your team still needs to write the eval config, decide what counts as a failure, and check that reports do not expose sensitive data. Outside help is most useful when the pipeline has many suites, strict review requirements, or must run inside a controlled network.

Is the promptfoo Community edition enough for CI runs?

For many teams it is enough, because the Community edition includes all LLM evaluation features, all model providers and integrations, and red teaming with 10k probes per month, with community support. The Enterprise edition adds team sharing, teams-based access control and SSO, custom roles and permissions, continuous monitoring, and priority support with SLAs. Those features matter when several teams share results, when access must follow your identity policy, or when you need a central view across pipelines. Confirm current edition details on the promptfoo pricing page before you decide.

Where should the promptfoo reports from Bitbucket go?

Store the reports as pipeline artifacts so reviewers can open them from the Bitbucket run, and set a retention period that your data policy allows. Reports can contain prompts, model outputs and parts of test data, so treat them as sensitive. Restrict who can read them and confirm that no provider key or secret is written into a file that gets archived. Check the Bitbucket artifact settings and your organization's retention rules before the first run.

How DeployOpen scopes and delivers the Bitbucket promptfoo step

DeployOpen treats the promptfoo step in Bitbucket Pipelines as a small, owned piece of your delivery system rather than a one-off script. We agree the scope in writing, build the pipeline file and its variables in your repository, and hand over documentation your team can run and change. Engagements are fixed-scope, and ongoing support is available as a retainer.

How we scope

  • Confirm which promptfoo evals and red team scans should run on pull requests, branches or a schedule in Bitbucket.
  • List the LLM provider keys the run needs and agree how each is stored as a repository variable.
  • Agree where reports go as pipeline artifacts, who reviews them and how long they are kept.

How we build

  • Write the bitbucket-pipelines.yml step on the node:24 image, pinning the promptfoo version you approve.
  • Configure secured repository variables and confirm that keys stay masked in build logs.
  • Test the step on a sample branch, including a deliberately failing eval, before it is applied to protected branches.

How we hand over

  • Deliver the pipeline file, configuration files and a written runbook for your platform team.
  • Walk through how to rotate provider keys, update the promptfoo version and read stored reports.
  • Document the open items to confirm with your security team, such as who can view repository variables.

How we support

  • Offer a retainer for upgrades, pipeline changes and retesting after promptfoo or Bitbucket changes.
  • Review pipeline logs and artifacts with your team when a run fails or behaves unexpectedly.
  • Extend the setup to red team scans or additional repositories under the same agreed scope.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.