Skip to main content
Plans: Every plan. Who: an owner or admin creates the API token; anyone who can edit the pipeline adds the steps.
These two steps install Syft, generate a CycloneDX JSON SBOM of the repository and send it to Pharus. They are the same steps as the Azure DevOps tab of Connect a pipeline on the SBOMs page.

Before you start

1

Create a token

In Pharus, go to Settings → API tokens and create a token for the product family. See create a token.
2

Store it as a secret variable

In Azure DevOps, edit the pipeline, select Variables, and add a variable named PHARUS_TOKEN with the token as its value. Tick Keep this value secret. A variable group works too.
Azure Pipelines doesn’t pass secret variables to scripts by itself. The env: block on the second step maps PHARUS_TOKEN into the script; keep it.

The pipeline

A complete azure-pipelines.yml that runs on every push to main. The name: line sets the build number, which becomes the product version in Pharus.
To add Pharus to an existing pipeline, copy only the two steps, and set name: to your product version. What it does:
  • Generate SBOM installs Syft into the agent’s temporary directory and writes sbom.cdx.json from the checked-out repository.
  • Send SBOM to Pharus gzips the file and posts it to POST /api/v1/sboms. Azure DevOps fills in the $(…) values before the script runs. Pharus removes refs/heads/ from the branch.
  • --fail-with-body fails the step on any error and prints Pharus’ message in the log.

Variations

Use -o spdx-json=sbom.spdx.json in the first step and gzip sbom.spdx.json in the second. Pharus reads SPDX JSON 2.2 and 2.3.
Replace dir:. with the image reference, for example myregistry.azurecr.io/gateway-g3:4.2. The agent must be able to pull the image.
Each build number, such as 4.2.17, is its own product version in Pharus, so every build adds an active SBOM to the family. If you build often, put your release version in X-Pharus-Version instead, for example from a variable such as $(productVersion). A new SBOM for a version replaces the previous SBOM of that version. You can also retire old SBOMs on their page in Pharus.

Check that it worked

The Send SBOM to Pharus log shows Pharus’ answer, with "status":"parsed" for a new SBOM and "duplicate":true when Pharus already had the file. In Pharus, the SBOM appears under SBOMs with Azure DevOps as its Source, and the token’s Last used time changes under Settings → API tokens. All codes are listed under errors.

Upload an SBOM

API introduction

GitHub Actions

GitLab CI