Continuous integration
Run build, test, and a vulnerability scan on every change, and keep main in a state you can release.
The source control lab blocks a merge until a check named verify is green. This lab is that check. Every push and every pull request builds the code, runs the tests, writes a software bill of materials, and fails if the vulnerability scan reports a high or critical finding.
The DevOps overview calls this the loop that keeps main releasable. Releasable means you can tag main and deploy that tag. It does not mean you deploy every commit. It means a commit that cannot be built or cannot pass its tests never sits on main.
Jenkins, GitLab CI, and OpenShift Pipelines are three ways to run the same script. The script is the contract. The engine is replaceable.
Prerequisites
- JDK 21 and Maven
- A Git repository whose default branch is
main, with the protection from the source control lab - Grype on the machine that runs the job, or Podman so you can run the Grype image
The commands use a Maven project. The Inventory API, the catalog, and the label servlet all build with mvn verify.
The script
Save ci/verify.sh at the root of the repository and make it executable (chmod +x ci/verify.sh). Commit that bit with the file (git add --chmod=+x ci/verify.sh). A runner that sees a non-executable file stops before Maven starts.
#!/bin/sh
set -eu
mvn -B verify
mvn -B org.cyclonedx:cyclonedx-maven-plugin:2.9.3:makeAggregateBom \
-DoutputFormat=json -DoutputName=bom -DoutputDirectory=target
if command -v grype >/dev/null 2>&1; then
grype sbom:target/bom.json --fail-on high
else
podman run --rm -v "$PWD:/work:Z" -w /work docker.io/anchore/grype:latest \
sbom:target/bom.json --fail-on high
fi
set -eu stops the script on the first failing command. Three stages, in order:
- Build and test.
mvn verifycompiles, runs unit tests, and runs any integration tests bound to the verify phase. A project with no tests still has to compile. Add a test before you trust the green bar. - Bill of materials. CycloneDX plugin 2.9.3 writes
target/bom.json. The-Dflags pin the path, including on a Spring Boot build whose parent would otherwise put the file underMETA-INF/sbom. The file lists the components that went into this build. Keep it with the artifact you publish. A bill of materials generated later from a different checkout describes a build you did not ship. - Scan. Grype reads that file and exits non-zero when it finds a high or critical finding. Medium and low do not fail this job. Whether medium fails the pipeline is a policy decision, made in the open with the security review, and then changed in this script. Do not silence a finding to get a green build.
Run it locally before you push:
./ci/verify.sh
echo $?
A non-zero status is a failed check. Fix the code or the dependency, and run the script again. The job on the server runs this file. It does not grow a second copy of the commands.
Wire it to the branch
The job name that GitHub branch protection looks for is verify. On GitHub Actions, .github/workflows/verify.yml:
name: verify
on:
pull_request:
push:
branches: [main]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "21"
cache: maven
- run: ./ci/verify.sh
The job id verify is the context in protection.json from the source control lab. If the pull request lists the check under a longer name, gh pr checks prints the string to put in that file. strict on that protection means a pull request has to be rebased onto current main and pass again. Two green branches can still break each other if you merge them in an untested order.
GitLab runs the same file. In .gitlab-ci.yml:
verify:
image: maven:3.9-eclipse-temurin-21
script:
- ./ci/verify.sh
The job name is verify. Mark that job as a required pipeline in the project settings. The GitLab CI lab fills this file out.
Jenkins runs it from a stage named Verify. The Jenkins lab is the Jenkinsfile. The stage is one line: sh './ci/verify.sh'.
OpenShift Pipelines runs it as a Tekton step in a Task. The OpenShift Pipelines lab is that Task. Point the step at this script so a green Pipeline and a green GitHub check mean the same thing.
Keep main releasable
A pull request merges only when verify is green and a reviewer has approved it. After the merge, the push to main runs the script again. If that run fails, main is red and the next change is a fix, not a feature. You do not force-push the bad commit away. Protection already rejects a force-push.
Deploy from a tag on main, or from main itself. Do not deploy a feature branch. The container image built for a release is built from that same commit, which is the container builds lab. The scan in this script looks at Maven dependencies. The image scan looks at the base image and the packages in the layers. Both have to pass before the tag is the one you roll out. Image policy and signing are the DevSecOps lab.
When the scan fails, read the Grype table, then decide. Upgrade the dependency and run ./ci/verify.sh again. A suppression belongs in a file you review, with a reason and a date, and the script should still fail on everything else. An empty suppression file that ignores the whole report is how a green check stops meaning anything.
What a green main is worth
You can check out main and build it. You can read target/bom.json and see the components. You can tag it:
git switch main
git pull
git tag -a rel-2026-10-29 -m "Inventory 1.0.0, verify green"
git push origin rel-2026-10-29
The tag message records intent. The guarantee is the check that ran on that commit, which you can see on the pull request and on the push.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Protection never sees verify |
The workflow job id is different | Name the job verify, matching protection.json |
target/bom.json is missing |
The CycloneDX goal did not run | Run the second mvn line on its own and read the plugin error |
| Grype cannot start in the pod | No binary and no Podman | Install Grype in the runner image, or use the podman run line |
main is red after a merge |
The two branches were not combined when they were tested | Rebase onto main (the strict setting) and fix the new failure |
| The job is green and the app still fails its tests | Tests are skipped, or there are none | Drop -DskipTests if it crept in; add a test that would have caught it |
What's next
Container builds turns a green commit into an image. Jenkins, GitLab CI, and OpenShift Pipelines are the engines. DevSecOps is the image scan and the signature that follow this dependency scan.