Jenkins
Gebruik een declarative pipeline-stage voor bestaande Jenkins-omgevingen.
Wat je nodig hebt
- Secret text credential watchtower-token
- Syft en curl op de build-agent
- WATCHTOWER_URL als vertrouwde pipelinevariabele
- Een declarative Jenkinsfile
-
1
Voeg een vaste post-build stage toe
withCredentials maskeert het token. De shell krijgt alleen de secret zolang de stap draait.
stage('Publish SBOM') { steps { sh 'syft dir:. -o cyclonedx-json=sbom.cdx.json' withCredentials([string(credentialsId: 'watchtower-token', variable: 'WT_TOKEN')]) { sh '''curl --fail-with-body "$WATCHTOWER_URL/api/inventory/sbom" \\ -H "X-Inventory-Token: $WT_TOKEN" -H "X-Asset-Name: $JOB_BASE_NAME" \\ -H "Content-Type: application/vnd.cyclonedx+json" \\ -H "X-Environment: production" -H "X-Hostname: jenkins" \\ -H "X-Build-Number: $BUILD_NUMBER" -H "X-Commit-Sha: $GIT_COMMIT" \\ --data-binary @sbom.cdx.json''' } } } -
2
Gebruik één shared-library helper
Leg uploadlogica en headers vast in een gedeelde pipeline library; teams kiezen alleen target en omgeving.
-
3
Schakel de gate gefaseerd in
Meet eerst false positives en responstijd voordat een 409-response deployments blokkeert.
Klaar wanneer het bewijs zichtbaar is
Controleer in Watchtower of de bron recent is, het componentaantal logisch is en de releasecontext bij de juiste asset staat. Een geslaagde HTTP-call alleen is niet genoeg.