Skip to content

Commit

Permalink
Determine the sbom target file name more robust.
Browse files Browse the repository at this point in the history
  • Loading branch information
netomi committed Nov 23, 2023
1 parent bda0f3c commit 6a5a1c9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sbin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -848,11 +848,16 @@ generateSBoM() {
local classpath="$(getCyclonedxClasspath)"

local sbomTargetName=$(echo "${BUILD_CONFIG[TARGET_FILE_NAME]//-jdk/-sbom}.json")
# if the replacement did not work as the target file name does not contain the pattern '-jdk',
# construct the sbom name by just appending '-sbom.json' to the target file name.
if [[ ${sbomTargetName} != *"-sbom"* ]]; then
sbomTargetName=$(echo "${BUILD_CONFIG[TARGET_FILE_NAME]}-sbom.json")
fi
# Remove the tarball extension from the name to be used for the SBOM
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]]; then
sbomTargetName="${sbomTargetName//\.zip/}"
sbomTargetName="${sbomTargetName//\.zip/}"
else
sbomTargetName="${sbomTargetName//\.tar\.gz/}"
sbomTargetName="${sbomTargetName//\.tar\.gz/}"
fi

local sbomJson="$(joinPath ${BUILD_CONFIG[WORKSPACE_DIR]} ${BUILD_CONFIG[TARGET_DIR]} ${sbomTargetName})"
Expand Down

0 comments on commit 6a5a1c9

Please sign in to comment.