There is no Bitbucket pipe from TRUSTIVAN. The recipe downloads the trustivan CLI, a single static binary, and runs trustivan gate in the step’s script. The gate requests a scan, waits for it, asks for a verdict and exits 1 when the policy blocks the build.

Prerequisites

  • An API key with scans:create, scans:read and verdicts:request, plus findings:read for the SARIF file. Add it as a secured repository or deployment variable named TRUSTIVAN_API_KEY. See Scopes.
  • An enabled policy in the organization, or a policy id to pass with --policy. Without one the verdict request answers 409. See Gate a pipeline on a policy.
  • The image already pushed to a registry TRUSTIVAN can pull from. TRUSTIVAN pulls it itself; a private registry needs a credential stored in TRUSTIVAN first. See Scan a private registry image.

The pipeline

bitbucket-pipelines.yml
Bitbucket masks a secured variable in the log and passes it to the script as $TRUSTIVAN_API_KEY, which is where the CLI reads it. $BITBUCKET_PIPELINE_UUID is the idempotency key, so re-running a failed step reuses its scan instead of queueing a second one. capture-on: always keeps the SARIF file on a blocked build, which is the build it matters for. To pin a CLI release, replace latest/download with download/<tag> in both URLs.

What it gates on

Bitbucket fails the step on both. A failed scan is never treated as a pass. The default wait is 20 minutes; change it with --timeout 30m, and keep it below the step’s max-time.

See the results

  • The step log has the verdict, the policy and version, the scan id and every rule, with ! beside the ones that fired.
  • The step’s Artifacts tab has trustivan.sarif, which any SARIF 2.1.0 viewer opens.
  • The dashboard has the scan and its findings under the asset.

Report without blocking

Accept exit 1 and nothing else, so an outage still fails the step:

Troubleshooting

See also