Jenkins & CI/CD

Publish native LoadStride reports and preserve threshold failures in Jenkins.

Choose the right working directory. Examples using npm run shortcuts, node bin/loadstride.js, or top-level starter-kit/ paths run from the LoadStride source checkout. Those shortcuts do not exist in your application’s package.json. Installed-package users run npx --no-install loadstride from their application directory. See Getting started for both options.

Jenkins reports

Jenkins can publish each build’s LoadStride HTML report and retain its JSON as a downloadable artifact. A report server process is not required for this workflow.

The complete source-checkout example is starter-kit/ci/Jenkinsfile.

Setup

  1. Put the project in the intended source repository and configure a Jenkins Pipeline job from SCM, using starter-kit/ci/Jenkinsfile as the script path (or copy/adapt it to the repository’s root Jenkinsfile).
  2. Use a Unix agent with Node.js 20 or newer on PATH. HTTP mode requires no external runtime packages; the example runs the source CLI. It uses the existing load-tests/api.js workload, whose checks should be edited for your application.
  3. Install the Jenkins HTML Publisher plugin.
  4. Set the job’s TARGET_URL, VUS, and DURATION parameters. The target must be reachable from the agent. The default local demo must be started separately; 127.0.0.1 means the agent, not your laptop.

The pipeline first clears only reports/jenkins/, before checkout, so reused workspaces cannot publish an older run when checkout or test setup fails. It disables concurrent builds for the same job and retains 30 builds by default. Adjust those values to your team’s retention policy.

Stable output paths and build outcome

The underlying test command is:

node bin/loadstride.js run load-tests/api.js --no-env --engine http --executor constant-vus \
  --url "$TARGET_URL" --vus "$LOADSTRIDE_CI_VUS" --duration "$LOADSTRIDE_CI_DURATION" \
  --json reports/jenkins/report.json --html reports/jenkins/report.html --html-external-css

The Jenkinsfile maps the job parameters to these quoted environment variables. It does not interpolate parameter values directly into shell source. --no-env skips the local env file; shell environment values still apply where not overridden. Replace the source workload path and pass application credentials through Jenkins credentials bindings if your own script needs them.

Using explicit paths makes the publish location predictable for the current build. Local interactive runs can keep using unique directories via --report-dir. Do not append --json/--html to an npm shortcut that already sets --report-dir.

Normal LoadStride exit codes are preserved: 0 passes; 1 means threshold/iteration failure; 2 means configuration/runtime error; 130 means interrupted execution. The shell step fails for nonzero exits. The example does not swallow failures using || true. Jenkins job cancellation follows Jenkins’ own abort handling.

In post { always { ... } }, the example publishes an HTML link if a report exists and archives JSON/HTML/CSS even on failed builds. Artifact archival is attempted in a finally block if HTML publication fails. Configuration/hook errors may produce no report; the original nonzero exit still fails the build, and no stale report is published. The HTML link appears as LoadStride report.

Jenkins content security policy

Jenkins’ default policy blocks inline CSS. --html-external-css writes styles into report.html.css next to the report and links it as a same-origin stylesheet. The HTML Publisher example includes both files. LoadStride’s report has no browser JavaScript, and this option does not require disabling Jenkins’ global content policy. Without the flag, reports remain self-contained as before. Keep both files together when using the flag; JSON is unchanged.

The serving layout was checked locally in Chromium under a policy matching Jenkins’ documented defaults. Actual Jenkins job/plugin configuration still needs validation on your Jenkins installation; no live Jenkins instance was available in this workspace. Plugin wrapper/custom proxy policies can differ. Your Jenkins administrator can use its supported resource-root setup when needed.

Primary references: HTML Publisher pipeline step, artifact archival, Declarative Pipeline post sections, Jenkins content security policy.

Shared server and Allure

For one company-wide report index, copy each build’s generated output into its own directory on persistent report storage, preserving filenames, then use the LoadStride report server. Do not overwrite another build’s folder or leave a server attached to an agent that is deleted after the job. Jenkins already provides access control when reports are published on its build pages; separately hosted reports use the company’s proxy/access policy.

Optional Allure export is the next phase. This implementation publishes native LoadStride HTML/JSON/CSS and does not produce allure-results yet. Allure’s Jenkins plugin alone cannot convert LoadStride JSON: an exporter must first supply its result format and performance summaries. LoadStride remains responsible for histogram calculations and threshold outcomes.

Based on the released v0.2.0 guide. View source on GitHub.