# Add an SBOM to CI for a Maven Project

Yes. An agent adds the CycloneDX plugin your Spring Boot parent configures, exposes the SBOM through the actuator, uploads it from CI, and opens a PR with proof.

[Run this on Rush](https://cloud.getrush.ai/run/add-sbom-to-ci/maven/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the build before it adds a plugin to it, because a Spring Boot parent already manages more than most teams know. In a project laid out like spring-petclinic/spring-petclinic-rest, `pom.xml` inherits from `spring-boot-starter-parent` 4.1.1, pulls in `spring-boot-starter-actuator`, `spring-boot-starter-webmvc`, `spring-boot-starter-security`, `spring-boot-starter-data-jpa` and the H2, HSQLDB, MySQL and PostgreSQL drivers, and already runs `jacoco-maven-plugin` with coverage limits, `openapi-generator-maven-plugin` from `src/main/resources/openapi.yml`, `maven-enforcer-plugin`, `jib-maven-plugin` for the Docker image, and the `build-info` goal of `spring-boot-maven-plugin` so the actuator can show build details. There is no `cyclonedx` plugin anywhere in the file. `application.properties` sets `server.port=9966` and `server.servlet.context-path=/petclinic/`, leaves `management.endpoints.web.exposure.include` at its default, which exposes only `health` over HTTP, and has `petclinic.security.enable=false`. `.github/workflows/maven-build-pull-request.yml` runs `./mvnw -B verify` on JDK 17 with Maven caching; `maven-build-master.yml` adds a SonarCloud scan, `docker-build.yml` pushes the image with Jib, and `newman-pipeline.yml` starts the app and runs the Postman collection. `.github/dependabot.yml` already updates Maven dependencies monthly, which is exactly when the SBOM should change.

Spring Boot's build documentation says the starter parent includes a pre-configured `cyclonedx-maven-plugin`, so the agent adds the plugin declaration with its `groupId` and `artifactId` and no version or executions to the `build` section of `pom.xml`, then reads the effective POM with `./mvnw help:effective-pom` to see what the parent bound: the goal, the phase, the output format and where the file lands in the jar. It writes those four facts into the pull request rather than asserting them, because they are the parent's choices and change with its version.

Then it makes the SBOM reachable at runtime. The actuator's `sbom` endpoint lists the SBOMs the application carries at `/actuator/sbom` and returns one at `/actuator/sbom/{id}`, in this project under the `/petclinic` context path, but only once it is exposed, so the agent adds `sbom` beside `health` in `management.endpoints.web.exposure.include` in `application.properties` and leaves every other endpoint unexposed. It reads `BasicAuthenticationConfig` and `DisableSecurityConfig` in the `security` package, which `petclinic.security.enable` switches between, so that enabling security later still lets the endpoint answer as the team intends, and says what it found.

In CI the agent changes `maven-build-pull-request.yml` only: after `./mvnw -B verify`, an `actions/upload-artifact` step publishes the generated CycloneDX file under the path the effective POM named, so every pull request carries its own SBOM as a downloadable artifact. To check all of it in its sandbox, the agent runs `./mvnw -B verify`, lists the file in `target/`, unzips the jar to show the SBOM inside it, starts the app with `./mvnw spring-boot:run`, and requests `/petclinic/actuator/sbom` and `/petclinic/actuator/sbom/application`, pasting the `ids` list, the `bomFormat`, `specVersion` and `serialNumber` lines and the component count into the pull request.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add a CycloneDX SBOM to this Maven project and publish it from CI. Read pom.xml, src/main/resources/application.properties, the security configuration under src/main/java, .github/dependabot.yml and every workflow under .github/workflows first. Add the cyclonedx-maven-plugin declaration to the build plugins with no version, since spring-boot-starter-parent pre-configures it, then run ./mvnw help:effective-pom and record the goal, phase, format and output path the parent bound. Add sbom to management.endpoints.web.exposure.include beside health and nothing else. In maven-build-pull-request.yml, upload the generated SBOM as a workflow artifact after verify. Run ./mvnw -B verify, show the SBOM inside the built jar, start the app with spring-boot:run and request /petclinic/actuator/sbom and /petclinic/actuator/sbom/application. Open a pull request with the effective POM facts, the jar listing and both responses. Do not change the master, Docker or Newman workflows.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The pull request changes `pom.xml`, `src/main/resources/application.properties` and `.github/workflows/maven-build-pull-request.yml`. Its description quotes the plugin binding from the effective POM, the `unzip -l` line showing the SBOM inside the jar, the `ids` response from `/petclinic/actuator/sbom`, the header of the CycloneDX document from `/petclinic/actuator/sbom/application`, and the `./mvnw -B verify` summary with the JaCoCo check still passing.

The `Java CI for Pull Request` workflow runs on the pull request with the new artifact attached to the run, so a reviewer downloads the SBOM GitHub produced rather than trusting the one from the sandbox. The master, Docker and Newman workflows are untouched.

Before merging, a reviewer decides whether the SBOM artifact should also be attached to releases or pushed to a dependency-tracking service, whether `/actuator/sbom` should stay exposed once `petclinic.security.enable` is turned on, and whether Dependabot's monthly Maven pull requests should carry a diff of the SBOM in their description.

## Run it on every Maven repository without an SBOM

A platform team with many Spring Boot services sends this body once per repository from its own server, each a `POST /o/{org}/sessions` with the repository in `resources` and a `request_id` that is a UUID v5 of the repository's full name, so a retried call returns the run already started rather than opening a second pull request. Each run reads its own parent: a project on a Spring Boot version whose parent does not pre-configure the plugin gets a pinned version and an explicit execution, a multi-module build gets the aggregate goal at the root, and a project without the actuator gets the build-time file and no endpoint change.

The key's `webhook_url` reports each `run.completed` with the pull request in `result`, and a run past the key's `max_concurrent` limit answers `202` with `status: "queued"` and starts when a slot frees, so the whole estate can be sent in one loop with no retries.

## Why run it on Rush?

The SBOM plugin is one declaration, and what it does depends on a parent POM the team did not write: which goal, which phase, which format, where the file lands. The agent reads the effective POM in its own sandbox instead of guessing, builds the jar and opens it, and starts the application to read the endpoint, so every claim in the pull request is something it saw.

The build, the jar listing and both actuator responses stay with the run and are quoted in the pull request. A team that owns dozens of Spring Boot services runs this across all of them at once and gets one pull request per repository, each with its own SBOM attached to its own CI run.

## Frequently asked questions

### Why no version on the plugin?

Because Spring Boot's build documentation says `spring-boot-starter-parent` includes a pre-configured `cyclonedx-maven-plugin`, so the declaration inherits the version, goal and phase the parent chose, and Dependabot's existing Maven entry moves them when the parent moves. The agent reads the effective POM to show what was inherited rather than repeating it in the project's own file.

### Why expose only sbom and health?

Because `management.endpoints.web.exposure.include` is a list, and the project's default exposes only `health`. Adding `sbom` beside it keeps `env`, `beans` and the rest unexposed. The project runs with `petclinic.security.enable=false`, so the description also says what happens to the endpoint when security is turned on.

### What is in the SBOM?

A CycloneDX document listing the application's components, their versions and their licenses as Maven resolved them for the build. The agent pastes its `bomFormat`, `specVersion` and `serialNumber` and the component count from the sandbox build, and the artifact on the CI run holds the full file for the pull request's own resolution.

### Does this touch the Docker image?

No. `docker-build.yml` builds the image with Jib on pushes to master and is left alone. Because the SBOM is inside the jar the image carries, the running container answers `/petclinic/actuator/sbom/application` the same way the sandbox did, which the description notes as something to check on the next image.

## More Maven jobs

- [Add SpotBugs to a Maven Build](https://getrush.ai/run/add-spotbugs/maven/)
- [Add Spotless Formatting to a Maven Build](https://getrush.ai/run/add-spotless-formatting/maven/)
- [Fix "Source option 5 is no longer supported. Use 7 or later." in Maven](https://getrush.ai/run/fix-source-option-5-no-longer-supported/maven/)

## The same job on other stacks

- [Add an SBOM to a Gradle Build's CI](https://getrush.ai/run/add-sbom-to-ci/gradle/)

## More jobs like this: Hand off a long task

- [Add an SBOM to the Release of a Cobra CLI](https://getrush.ai/run/add-sbom-to-release/cobra/)
- [Add an SBOM to a Go CLI's GoReleaser Release](https://getrush.ai/run/add-sbom-to-release/go-cli/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
