Skip to content

Commit ff02839

Browse files
authored
Merge pull request #90 from android/riggaroo/kokoro-intoto
Update build scripts to improve intoto.jsonl file handling
2 parents 2e993b5 + 6bcaa03 commit ff02839

File tree

6 files changed

+57
-23
lines changed

6 files changed

+57
-23
lines changed

app/build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ plugins {
2626
alias(libs.plugins.crashlytics)
2727
alias(libs.plugins.baselineprofile)
2828
id("com.google.android.gms.oss-licenses-plugin")
29+
id("org.spdx.sbom") version "0.9.0"
2930
}
3031

3132
android {
@@ -99,6 +100,16 @@ baselineProfile() {
99100
dexLayoutOptimization = true
100101
}
101102

103+
spdxSbom {
104+
targets {
105+
// create a target named "release",
106+
// this is used for the task name (spdxSbomForRelease)
107+
// and output file (release.spdx.json)
108+
create("release") {
109+
configurations.set(listOf("releaseRuntimeClasspath"))
110+
}
111+
}
112+
}
102113
dependencies {
103114
debugImplementation(libs.leakcanary.android)
104115
implementation(libs.androidx.app.startup)
@@ -155,3 +166,4 @@ androidComponents {
155166
variantBuilder.enableAndroidTest = false
156167
}
157168
}
169+

build.sh

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ echo "INFO: Cleaning the project..."
9595

9696
# Build the production release bundle without generating a baseline profile.
9797
echo "INFO: Building the production release bundle..."
98-
./gradlew app:bundleRelease -x test -Pandroid.sdk.path=$ANDROID_HOME -PCI_BUILD=true
98+
./gradlew app:bundleRelease app:spdxSbomForRelease -x test -Pandroid.sdk.path=$ANDROID_HOME -PCI_BUILD=true
9999

100100
# --- Artifact Collection ---
101101
echo "INFO: Preparing artifacts for Kokoro..."
@@ -116,17 +116,26 @@ if [[ -f "$AAB_PATH" ]]; then
116116
cp "${AAB_PATH}" "${ARTIFACT_DEST_DIR}/app-release-unsigned.aab"
117117
echo "SUCCESS: AAB copied to ${ARTIFACT_DEST_DIR}"
118118

119-
# Copy any .intointo.jsonl files to the artifact directory
120-
echo "INFO: Searching for and copying .intointo.jsonl files..."
121-
ls
122-
echo "INFO: Logging output directory contents"
123-
ls "$AAB_SRC_DIR/"
124-
find . -type f -name "*.intointo.jsonl" -print0 | xargs -0 -I {} cp {} "${ARTIFACT_DEST_DIR}/"
125-
echo "INFO: Finished copying .intointo.jsonl files."
119+
# Find and list the files before copying
120+
# Store the find results in a variable to avoid running find twice
121+
# and to handle the case where no files are found gracefully.
122+
intoto_files=$(find . -type f -name "*.intoto.jsonl")
123+
124+
if [ -n "$intoto_files" ]; then
125+
echo "INFO: Found the following .intoto.jsonl files:"
126+
echo "$intoto_files" # This will list each file on a new line
127+
echo "INFO: Copying .intoto.jsonl files to ${ARTIFACT_DEST_DIR}/"
128+
# Use print0 and xargs -0 for safe handling of filenames with spaces or special characters
129+
find . -type f -name "*.intoto.jsonl" -print0 | xargs -0 -I {} cp {} "${ARTIFACT_DEST_DIR}/"
130+
else
131+
echo "INFO: No .intoto.jsonl files found."
132+
fi
126133

127-
else
128-
echo "FAILURE: AAB not found at ${AAB_PATH}"
129-
# Optionally fail the build: exit 1
130-
fi
134+
echo "INFO: Copying SPDX SBOM..."
135+
# The output file from app:spdxSbomForRelease is build/spdx/release.spdx.json
136+
cp app/build/spdx/release.spdx.json "${KOKORO_ARTIFACTS_DIR}/artifacts/app-release.spdx.json"
131137

132-
exit 0
138+
else
139+
echo "FAILURE: AAB not found at ${AAB_PATH}"
140+
exit 1
141+
fi

build_presubmit.sh

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ echo "INFO: Cleaning the project..."
9696

9797
# Build the production release bundle without generating a baseline profile.
9898
echo "INFO: Building the production release bundle..."
99-
./gradlew app:bundleRelease -x test -x uploadCrashlyticsMappingFileRelease -Pandroid.sdk.path=$ANDROID_HOME -PCI_BUILD=true
99+
./gradlew app:bundleRelease app:spdxSbomForRelease -x test -x uploadCrashlyticsMappingFileRelease -Pandroid.sdk.path=$ANDROID_HOME -PCI_BUILD=true
100100

101101
# --- Artifact Collection ---
102102
echo "INFO: Preparing artifacts for Kokoro..."
@@ -117,17 +117,28 @@ if [[ -f "$AAB_PATH" ]]; then
117117
cp "${AAB_PATH}" "${ARTIFACT_DEST_DIR}/app-release-unsigned.aab"
118118
echo "SUCCESS: AAB copied to ${ARTIFACT_DEST_DIR}"
119119

120-
# Copy any .intointo.jsonl files to the artifact directory
121-
echo "INFO: Searching for and copying .intointo.jsonl files..."
122-
ls
123-
echo "INFO: Logging output directory contents"
124-
ls "$AAB_SRC_DIR/"
125-
find . -type f -name "*.intointo.jsonl" -print0 | xargs -0 -I {} cp {} "${ARTIFACT_DEST_DIR}/"
126-
echo "INFO: Finished copying .intointo.jsonl files."
120+
# Find and list the files before copying
121+
# Store the find results in a variable to avoid running find twice
122+
# and to handle the case where no files are found gracefully.
123+
intoto_files=$(find . -type f -name "*.intoto.jsonl")
124+
125+
if [ -n "$intoto_files" ]; then
126+
echo "INFO: Found the following .intoto.jsonl files:"
127+
echo "$intoto_files" # This will list each file on a new line
128+
echo "INFO: Copying .intoto.jsonl files to ${ARTIFACT_DEST_DIR}/"
129+
# Use print0 and xargs -0 for safe handling of filenames with spaces or special characters
130+
find . -type f -name "*.intoto.jsonl" -print0 | xargs -0 -I {} cp {} "${ARTIFACT_DEST_DIR}/"
131+
else
132+
echo "INFO: No .intoto.jsonl files found."
133+
fi
134+
135+
echo "INFO: Copying SPDX SBOM..."
136+
# The output file from app:spdxSbomForRelease is build/spdx/release.spdx.json
137+
cp app/build/spdx/release.spdx.json "${KOKORO_ARTIFACTS_DIR}/artifacts/app-release.spdx.json"
127138

128139
else
129140
echo "FAILURE: AAB not found at ${AAB_PATH}"
130-
# Optionally fail the build: exit 1
141+
exit 1
131142
fi
132143

133144
exit 0

kokoro/gcp_ubuntu_docker/continuous.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ action {
44
define_artifacts {
55
regex: "artifacts/**.aab"
66
regex: "artifacts/**.intoto.jsonl"
7+
sbom_regex: "artifacts/app-release.spdx.json"
78
# Optional: Removes the "artifacts/" part from the path in the artifact storage
89
strip_prefix: "artifacts"
910
fail_if_no_artifacts: true

kokoro/gcp_ubuntu_docker/presubmit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ action {
44
define_artifacts {
55
regex: "artifacts/**.aab"
66
regex: "artifacts/**.intoto.jsonl"
7-
7+
sbom_regex: "artifacts/app-release.spdx.json"
88
# Optional: Removes the "artifacts/" part from the path in the artifact storage
99
strip_prefix: "artifacts"
1010
fail_if_no_artifacts: true

kokoro/gcp_ubuntu_docker/release.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ action {
44
define_artifacts {
55
regex: "artifacts/**.aab"
66
regex: "artifacts/**.intoto.jsonl"
7+
sbom_regex: "artifacts/app-release.spdx.json"
78

89
# Optional: Removes the "artifacts/" part from the path in the artifact storage
910
strip_prefix: "artifacts"

0 commit comments

Comments
 (0)