-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create sbom and analyze it with dtrack
When generating standaldon sbom (not aggregated) we have a dependency graph for each single artifact.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
pipeline { | ||
agent any | ||
|
||
options { | ||
buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '20')) | ||
} | ||
|
||
triggers { | ||
cron '@midnight' | ||
} | ||
|
||
stages { | ||
stage('build') { | ||
steps { | ||
script { | ||
if (isReleaseOrMasterBranch()) { | ||
docker.build('maven').inside() { | ||
maven cmd: "org.cyclonedx:cyclonedx-maven-plugin:makeBom -DincludeLicenseText=true -DoutputFormat=json" | ||
withCredentials([string(credentialsId: 'dependency-track', variable: 'API_KEY')]) { | ||
def components = ["unit-tester", "primeui-tester", "web-tester"] | ||
for (component in components) { | ||
def version = sh (script: "mvn -f ${component}/pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout", returnStdout: true) | ||
sh 'curl -v --fail -X POST https://api.dependency-track.ivyteam.io/api/v1/bom \ | ||
-H "Content-Type: multipart/form-data" \ | ||
-H "X-API-Key: ' + API_KEY + '" \ | ||
-F "autoCreate=true" \ | ||
-F "projectName=' + component + '" \ | ||
-F "projectVersion=' + version + '" \ | ||
-F "bom=@unit-tester/target/bom.json"' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
def isReleaseOrMasterBranch() { | ||
return env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('release/') | ||
} |