Running promptfoo in Jenkins pipelines

Adding promptfoo evals to a Jenkinsfile takes a Node.js-capable agent, provider keys in Jenkins credentials and archived reports. This page covers the setup sequence and the agent problems that usually break the first run.

On this page

How promptfoo runs inside a Jenkins pipeline

A team that wants LLM evals gating changes in its existing Jenkins estate can add promptfoo as a CLI step in a Jenkinsfile. The documented approach is a pipeline stage that installs Node.js on the Jenkins agent, passes provider API keys in from Jenkins credentials, runs the promptfoo evaluation, and archives the HTML and JUnit output. The agent is where the work happens: promptfoo executes on that machine, reads your prompts and test configuration from the checked-out workspace, and calls the model provider directly over the network. Nothing is sent to a promptfoo service to run the eval, which matches the project's documented local operation.

This shape has consequences for ownership. Your Jenkins controller only schedules the job, so the agent needs outbound access to each provider endpoint, a Node.js version that meets the requirement stated in the promptfoo npm package, and enough disk for the promptfoo cache. Provider keys are exposed to the process running on that agent, so who can edit the Jenkinsfile, which agents carry the label, and whether builds from pull requests can read credentials are decisions to settle before the first run. Confirm with your platform team whether agents are ephemeral containers or long-lived machines, because that determines whether installed tooling and cache survive between builds.

Results follow the same path. promptfoo writes its output files into the workspace, and the pipeline publishes them so reviewers can open them from the build page. Because the report can include prompts, model responses and graded outputs, the archive should be treated as sensitive data with the same access rules as the repository. Before you copy the documented steps, check the current promptfoo Jenkins guide against the Jenkins plugins and agent image your organization already runs, since plugin names and agent labels vary between estates.

What a Jenkins agent needs before the first run

Most first Jenkins runs of promptfoo fail for reasons that sit outside the pipeline file: the agent lacks a suitable Node.js runtime, keys are not reachable from the job, or the agent cannot reach the model provider. Settle these four areas with the people who run your Jenkins controllers and agents before editing the Jenkinsfile.

Node.js runtime on the agent

promptfoo is installed through npm, so the agent needs Node.js on the PATH for the build user. The npm release 0.124.1 requires Node.js 22.22.0 or newer, so check the version on each agent label the pipeline can land on, not just the one you tested. The Jenkins guide lists missing Node.js on the agent as a common cause of failure. Confirm whether your agents are ephemeral containers or long-lived machines, because that decides where the runtime must be baked in.

promptfoo on npm

Provider keys in Jenkins credentials

Model provider API keys should be stored as Jenkins credentials and bound to environment variables only inside the stage that calls promptfoo. Avoid hardcoding keys in the Jenkinsfile or passing them as plain pipeline parameters, since those values can appear in build logs and configuration history. Ask who may create, rotate and read these credentials, and whether the folder or job scope limits access to the branches that should run evals.

Outbound network to model providers

Evals run locally and call the model provider directly, so the agent needs outbound HTTPS to each provider endpoint in the config, plus the npm registry for installation. Many regulated networks block general egress from build hosts, and a proxy may need settings that promptfoo and npm both honor. Test from the agent itself with a minimal request before blaming the pipeline, and confirm with your network team which endpoints and proxy settings apply.

Pipeline and credentials plugins

The Jenkinsfile needs the Pipeline plugin set and the Credentials Binding capability to inject secrets safely. Confirm which versions your controller runs and whether the plugins are approved under your change process, since plugin updates are often the trigger for an unexpected break. If you plan to publish HTML or JUnit results, confirm the reporting plugins that provide those steps are also installed and allowed on the agents that run the job.

Ownership of the agent image

Decide who owns the agent image or machine configuration before the first run: the platform team, the team that owns the Jenkins controller, or the team that owns the application. Whoever owns it should pin the Node.js version, apply patches and record changes, because a silent runtime upgrade can change promptfoo behavior between builds. Write the owner, the update path and the review step into the runbook so a broken agent does not stall every LLM change.

Configuring the Jenkinsfile step by step

This sequence takes a Jenkins controller and agent from no promptfoo setup to a pipeline that installs promptfoo, runs evals with provider keys held in Jenkins credentials, archives the HTML and JUnit results, and fails the build when a test regresses.

  1. Prepare the Jenkins agent with Node.js

    The Jenkins administrator or platform engineer confirms that the agent that will run promptfoo has Node.js installed and on the PATH, and that the version meets the promptfoo requirement. The current npm release requires Node.js 22.22.0 or newer, so check the installed version against that minimum before anything else. Missing Node.js on the agent is the most common reason a first run fails, and the promptfoo Jenkins guide lists it as a troubleshooting item. Confirm the setup by running a version check from a shell step on that agent, such as node --version and npm --version, and by checking that both print without error. If the agent is a container or a dynamically provisioned node, confirm the image or template includes Node.js, not just the host it was built from.

  2. Store each provider key as a Jenkins credential

    An administrator adds each model provider API key as a separate secret text credential in Jenkins, scoped to the folder or job that needs it instead of a global scope where possible. Use one credential ID per provider so that rotating one key does not affect the others, and record the IDs in your pipeline design notes. Keys should never be typed into the Jenkinsfile, the job configuration or a shared environment block. The step is done when each credential appears in the credentials list with the intended scope and when a test build can reference the ID without printing the value. Ask your Jenkins administrator to confirm who can view and edit these credentials under your access model.

  3. Add a stage that installs promptfoo

    The pipeline author adds a stage to the Jenkinsfile that installs promptfoo on the agent, typically through npm in a pinned or deliberately chosen version so that a new release does not change results between builds. Pin the version in your repository and record the reason for the choice, because evaluation results can shift when the tool changes. Keep this stage separate from the evaluation stage so that an install failure is easy to read in the Jenkins stage view. The step is complete when a build runs the install command and the following version check prints the expected promptfoo version in the console log.

  4. Bind credentials to environment variables inside the eval stage only

    The pipeline author wraps only the evaluation command in a withCredentials block, binding each credential ID to the environment variable name that promptfoo reads for that provider, such as the variable named in the provider documentation. Keeping the binding inside that single stage means the keys exist only while the evaluation runs and are not exposed to the install, archive or notification steps. Jenkins masks bound values in the console output, but masking is not a substitute for scope, so avoid echoing environment variables in any step. The step is verified by a build that runs successfully with the keys present, and by a deliberate env check on a throwaway branch that confirms the variables are absent outside the bound block.

  5. Run the evaluation and write HTML and JUnit output

    The pipeline runs the promptfoo evaluation command inside the bound block and writes results to files in the workspace: an HTML report for human review and a JUnit XML file for the Jenkins test tab. Use --output options to set the file names and keep the paths predictable so that the archive step can find them. Set the command to continue past a failing assertion where you want the reports written before the build is marked failed, and confirm the exact flags against the promptfoo documentation for the version you pinned. The step is done when both files exist in the workspace after a run, which you can confirm with a ls or dir command in the log.

  6. Archive the HTML report and publish JUnit results

    The pipeline author adds a post block that archives the HTML report with archiveArtifacts so reviewers can open it from the build page, and publishes the JUnit file with the JUnit step so failing test cases appear in the build's test tab. Use the post block so that the archive runs even when the evaluation stage fails. The step is complete when the build page lists the HTML artifact, the test results tab shows the case counts, and the reports open without errors. If the plugin for publishing JUnit is not installed on your controller, ask your Jenkins administrator to confirm it before you rely on this step.

  7. Confirm the build fails on a regression

    Before relying on the pipeline as a gate, the team introduces a deliberately failing test case on a throwaway branch, such as an assertion that the model output must contain a string the prompt will not produce. The build should finish with a failed status, the JUnit tab should show the failing case, and the HTML artifact should contain the failure detail. Then remove the deliberate failure and confirm the build returns to passing. This check proves that the exit code from promptfoo reaches Jenkins, which is the property that makes the stage a real gate. Record the result in the pipeline's documentation so future changes to the Jenkinsfile can be tested the same way.

Choosing where Node.js runs on Jenkins

A permanent Jenkins agent is a long-lived machine or virtual machine with Node.js installed once and reused by every build that lands on it. This is the simplest model to reason about, because the promptfoo command runs exactly as it would on a developer workstation, and the Node.js version is a property of the host rather than of each pipeline.

  • Low per-build overhead: Jobs start without downloading Node.js or npm packages from scratch, which keeps build times predictable on busy agents.
  • Shared state risk: Files left by one build, including promptfoo caches and result files, can be seen by the next build on the same host unless workspaces are cleaned.
  • Ongoing patching: Your platform team owns Node.js upgrades and must keep the version aligned with the promptfoo release you pin.
  • Access control is host-wide: Anyone who can run jobs on the agent may be able to read files or environment variables the host holds, so restrict which jobs can target it.
  • Drift between agents: Agents set up at different times can end up with different Node.js versions unless you manage them as code.

Before relying on this model, confirm the Node.js version the promptfoo release requires and check that your agent maintenance process updates it.

Mapping provider keys and outputs to Jenkins

This table maps each secret and output file in the promptfoo Jenkins job to its Jenkins credential, environment variable, config reader, archive path and reviewer. Read each row as one link in the chain from secret to reviewed result. The main takeaway is that HTML, JSON and JUnit files can contain prompts and model responses, so they need the same access rules as the build log.

ItemJenkins location or variableRead byWho reviews it
OpenAI API key (illustrative)Credential ID stored as secret text, bound to OPENAI_API_KEYProvider block in promptfooconfig.yaml reading the environment variablePipeline owner who rotates the key
Other provider keysOne credential ID per provider, each bound to its own variableMatching provider entries in the same config filePlatform team that manages credential scope
HTML reportArchived at promptfoo-results/report.html in the buildBrowser review from the Jenkins build pageEngineers who changed prompts or tests
JUnit XMLArchived at promptfoo-results/results.xml and read by the JUnit stepJenkins test results viewMerge reviewers checking failed cases
JSON outputArchived at promptfoo-results/results.json, if the job writes itScripts or downstream checks that parse resultsPipeline maintainers who own the parsing logic
Build console logJenkins build log, which can echo prompts on failureAnyone with build read accessSame audience as the archived files, so permissions must match
Output access ruleRestrict archived artifacts to the same folder or role as the jobJenkins authorization settingsSecurity or compliance lead to confirm before rollout

How a Jenkins build calls the model provider

The build starts with a developer push that triggers the Jenkins controller, which hands the job to an agent. The agent needs Node.js and promptfoo installed locally, because promptfoo runs on the machine and calls the model provider directly. Provider keys are bound from Jenkins credentials only into the agent's build step, so the controller never runs the evals. Check that the keys stay out of the console log and that the HTML and JUnit files are archived from the workspace.

Keys are injected on the agent, and only the agent calls the model provider.

Keeping provider keys and reports out of logs

Provider keys and red team reports are the two things a Jenkins promptfoo job can leak. The cards below cover where keys are bound, how the console and workspace expose them, who can read the job, and how archived files are handled after the build finishes.

Bind keys to the stage that needs them

Use the withCredentials step around only the command that calls the model provider, not at the top of the pipeline or in the environment block for every stage. A key scoped to one sh step is not present during checkout, dependency install or artifact archiving. Confirm that the eval stage is the only stage with OPENAI_API_KEY or similar variables in its scope.

Jenkins guide

Confirm masking before trusting it

Jenkins masks bound credential values in console output, but masking is a best-effort string match, so a value that is base64 encoded, split across lines or printed through a transformed format can still appear. Test masking on your Jenkins version with a dummy credential that echoes its value in a throwaway job. Treat masking as a second line of defense behind scoping.

Stop echoing environment variables

Commands such as env, printenv, set -x and verbose npm or promptfoo debug flags print variables to the console. Shell tracing is especially risky inside a withCredentials block because it prints the expanded command. Disable tracing in the eval stage, avoid env in troubleshooting steps, and review any --verbose or debug output before enabling it on a shared job.

Restrict who can read the job

Credential masking does not stop users with Read access from seeing console output, workspace files or archived artifacts on a job they can view. Limit job and folder permissions with the Jenkins authorization strategy in use, and keep the pipeline that binds provider keys in a folder accessible only to the team that owns the evals. Ask your Jenkins administrator to confirm which roles can view console output.

Limit agent workspaces shared between jobs

A Jenkins agent that runs several jobs may keep workspaces on disk after a build, and promptfoo writes its cache and config files into the project directory. Use a clean workspace step or ephemeral agents for eval jobs, delete the .promptfoo cache and any generated config holding secrets at the end of the run, and avoid running eval jobs on agents that also host untrusted builds.

Treat archived reports as sensitive

HTML and JUnit reports can contain prompts, model outputs and red team attack payloads that reveal system prompts or internal data. Decide retention for archived artifacts, restrict who can download them, and review the content before archiving reports from a red team scan. Confirm the retention settings on your Jenkins controller and whether reports must leave the environment at all.

Why the first Jenkins run usually fails

This table lists the failures that most often break a first promptfoo run on a Jenkins agent, with the cause and fix for each. Read it top to bottom before the first build, because several of these problems fail silently or look like a promptfoo error. The main takeaway is that most first-run failures come from the agent environment, not from the eval configuration.

FailureLikely causeFix
Node.js missing on the agentThe agent image or tool setup does not include Node.js, which the promptfoo Jenkins guide lists as a common issueInstall Node.js on the agent or use a Node tool or container image, then confirm with a version check in the first stage
Node version too oldThe installed Node.js is below the release promptfoo requires, which is 22.22.0 or newer for the 0.124.1 releaseUpgrade Node.js on the agent and pin the version the pipeline expects so later agent changes do not break builds
npx or npm not on PATHNode is installed but the shell in the pipeline step does not load its bin directoryPrint the npm and npx locations in a debug step, then fix the PATH in the agent configuration or the Jenkinsfile environment block
Provider key not bound or wrong credential IDThe withCredentials block uses an ID that does not exist, or the variable name does not match the key promptfoo readsCheck the credential ID in Jenkins, match the environment variable name to the provider's expected key, and confirm the binding in the job log
Outbound network blockedA proxy, firewall or egress rule stops the agent from reaching the model provider endpointsAsk the network team to allow the provider domains from the agent subnet, and set proxy variables for the agent if your network requires them
Workspace permissions block report writesThe Jenkins agent user cannot create or write the output directory or report filesWrite reports to the workspace directory, confirm the agent user owns it, and avoid system paths in the eval command
Archive paths do not match output filesThe archiveArtifacts or junit pattern points to a different path than the one promptfoo writesUse the same relative path in the eval output option and the archive step, then check the file exists before archiving

Questions teams ask before adding promptfoo to Jenkins

How much effort does a promptfoo Jenkins integration take for a team that already runs Jenkins?

For a team that already runs Jenkins pipelines, the core change is small: one new stage in a Jenkinsfile that installs Node.js dependencies, runs the eval, and archives the output. The effort is usually spent on the agent, not the pipeline code. Confirm three things before you start: whether the agent has a supported Node.js version (promptfoo's npm release 0.124.1 requires Node.js 22.22.0 or newer), whether the agent can reach your model provider's endpoints, and whether your team already has a pattern for Jenkins credentials. Effort rises quickly if agents are shared, locked down or built from old images.

What drives the ongoing cost of running promptfoo in Jenkins?

Cost has three parts, and only one of them is a software charge. promptfoo is MIT licensed and the Community edition is free, so the recurring costs are:

  • Agent maintenance: keeping Node.js, npm packages and agent images current, and fixing agents that drift.
  • Provider spend: every eval and grader call goes to your model provider and is billed by that provider.
  • Reviewer time: someone has to read failures, decide whether a regression is real, and tune assertions.

Provider spend grows with suite size, number of models compared and how often the pipeline runs. Ask any partner to separate one-time setup from these recurring items in a written quote.

Can an internal Jenkins team set up promptfoo on its own?

Yes, many internal teams can, provided they have someone comfortable with Jenkinsfile syntax, Node.js and the provider they test against. The first run usually fails for predictable reasons: Node.js missing on the agent, an old Node.js version, or provider keys not exposed to the step. Teams without agent administration rights or with a change process that takes weeks will move slower. A partner is most useful when the agent estate is complicated or when the pipeline must meet internal review standards from the start.

What does the work need from our team before it starts?

Plan to provide four things. First, access to the Jenkins controller and agents, or a named admin who can make changes. Second, a named owner for each provider credential, since keys must be stored in Jenkins credentials and rotated by someone accountable. Third, a sample eval suite, even a small one with a few representative prompts and assertions, so the first pipeline run tests something real. Fourth, a decision on where HTML and JUnit results should be reviewed. Ask the partner to list these inputs in the written scope so gaps show up before work begins.

How long does a promptfoo Jenkins integration take?

Duration depends mainly on the state of your agents and how far the scope goes. A working pipeline on an agent that already has a supported Node.js version is the shortest path. Adding agent provisioning, image changes, change approvals, multiple environments or a gate that blocks merges takes longer. No duration is supplied for this work, so ask for a timeline tied to your agent inventory and a list of milestones in the written scope, and check that the timeline counts approval steps on your side.

Is the promptfoo Community edition enough for Jenkins pipelines?

For running evals and red team scans from a Jenkins pipeline, the Community edition covers the core use case. It includes all LLM evaluation features, all model providers and integrations, and red teaming with 10k probes per month, with community support. Enterprise adds team sharing, SSO, role-based access control, continuous monitoring and priority support with SLAs, at custom pricing. Self-hosted promptfoo uses a local SQLite database that cannot be shared across replicas and is not recommended for production, so a shared server for many teams needs a different plan. Check the current edition details on the pricing page before you decide.

Does Jenkins need extra security controls for promptfoo runs?

Yes. The main exposure is provider keys, which must live in Jenkins credentials and be bound only to the steps that need them, not set globally on the agent. Confirm who can read the console output, since prompts, responses and sometimes provider errors can appear in logs. Archived HTML and JUnit reports can contain test data, so set retention and access on the build artifacts. Review the Jenkins plugin set and agent permissions with your security team before the pipeline runs against production model endpoints.

What this means for your pipeline ownership

Four things in a promptfoo Jenkins pipeline need a named owner before the first build runs: the agent image (the machine or container that provides Node.js), the credential store holding provider keys, the eval suite that defines what gets tested, and the gate threshold that decides whether a build fails. Each of these changes for different reasons, so they should not sit with one person by default. The agent image usually belongs to the platform or build engineering team, because they already patch and version Jenkins agents. The credential store belongs to security, who decide which provider keys exist, who can read them and how they rotate. Confirm which team controls each item in your environment before the pipeline goes live.

The eval suite and the gate threshold usually belong to the product team that owns the LLM application, since they know which regressions matter to users. Security should have a say in the red team scope if scans run in the same pipeline, and the threshold should be reviewed whenever the prompts, models or grader choices change. Ask the product team to write down why each threshold is set where it is, so a later change can be checked against that reasoning instead of against the pipeline's history.

Write the split into your Jenkins folder documentation or pipeline README, and check it at each Node.js upgrade on the agent and each provider key rotation. A simple test is whether someone outside the team can answer, from the repository alone, who to contact when a run fails because of an expired key, a missing runtime or a threshold no one can explain. If that question has no answer, the ownership model is not finished yet.

How DeployOpen scopes and delivers a Jenkins promptfoo integration

DeployOpen approaches a Jenkins promptfoo integration as a planned piece of your delivery pipeline, not a one-off script. We agree the scope in writing, build the pipeline on agents you control, and hand over a pipeline your own team can run, review and change after the engagement ends.

How we scope

  • Confirm which Jenkins controller and agents will run promptfoo, and whether they already have Node.js available
  • Map which provider keys the evals need and where each key is stored in Jenkins credentials
  • Agree in writing which suites run per commit, which run on demand, and which reports must be archived

How we build

  • Write the Jenkinsfile stages for install, eval run, HTML and JUnit output, and archiving on your agents
  • Test the first runs against a sample of your own eval configuration to surface agent and Node.js problems early
  • Confirm that provider keys are masked in console output and are not written into archived files

How we hand over

  • Document the Jenkinsfile, agent requirements, credential IDs and the steps to rotate provider keys
  • Walk your platform and security engineers through how reports are archived and where they are reviewed
  • Record the open decisions, such as caching and pass-rate thresholds, so your team can choose them deliberately

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover
  • Retainer scope is agreed in writing and can cover promptfoo version upgrades and Jenkins agent changes
  • Ask us to confirm response expectations and support hours in the written scope before work starts

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.