Blog

DarkMoon in Jenkins: a pipeline step that gates the build on real findings

A darkmoonScan() pipeline step that wraps the DarkMoon CLI on the agent, fails or marks the build unstable from the severity summary, maps findings to SARIF 2.1 for Warnings Next Generation, and keeps the token in the Jenkins Credentials store, never on the command line.

· 7 min read

CI is where security either becomes routine or stays a quarterly event. The DarkMoon Jenkins plugin adds a single pipeline step that runs an autonomous assessment on the agent and gates the build on what it actually finds, not on a scanner exit code.

One step

The plugin exposes a darkmoonScan(...) step. A minimal declarative usage:

stage('Pentest') {
  steps {
    darkmoonScan(
      target: 'https://staging.example.com',
      mode: 'pro',
      apiUrl: 'https://darkmoon.internal',
      credentialsId: 'darkmoon-token',
      failOn: 'critical,high',
      recordIssues: true,
      archiveReport: true
    )
  }
}

The step wraps the portable darkmoon-ci CLI on the agent (Node 18+). It launches and waits, reads the fail verdict and campaign id, then pulls findings, the severity summary and the report.

Gate the build from the severity summary

The build result is set from the finding severities, not from CLI exit codes: failOn marks the build a failure, unstableOn marks it unstable. A run that never completes within timeout is a failure, never a silent pass.

SARIF for Warnings Next Generation

Findings are mapped to SARIF 2.1.0 (darkmoon-reports/darkmoon.sarif) so the Warnings Next Generation plugin renders the severity donut, the trend and per-issue detail in the build view. The report, the SARIF file and the CLI log are archived as build artifacts.

Secrets never on the command line

The Pro token or license is read from the Jenkins Credentials API and passed to the CLI through environment variables (DARKMOON_PRO_TOKEN, DARKMOON_LICENSE), never on the command line, the console, or in artifacts. Pro authentication is token-only by design.

Auto or OSS or Pro

The mode parameter selects auto-detect, the open-source CLI reading a local data directory, or the Pro API. The same step works in all three, so a team can start on OSS and move to Pro without rewriting the pipeline.

The plugin targets Jenkins 2.479+ on JDK 17 and ships an .hpi via Releases. See the integrations catalog and the GitLab component for the same idea on another CI system.

Run it against your own lab

Darkmoon is open source (GPL-3.0) and self hosted. Clone it, point it at a target you own, and read every line.