Skip to content

Commit 04bac12

Browse files
jbachorikclaude
andcommitted
ci: detect corrupt JARs before build, disable build cache
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 174ea08 commit 04bac12

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

.gitlab/scripts/build.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,19 @@ echo "Using Java @ ${JAVA_HOME}"
2424

2525
source .gitlab/scripts/includes.sh
2626

27-
# Remove any zero-byte or corrupt JARs from the Gradle cache (can result from partial downloads)
28-
find .gradle -name "*.jar" -size 0 -delete 2>/dev/null || true
27+
# Remove corrupt JARs from Gradle caches (non-ZIP content from failed/proxied downloads)
28+
# JARs not starting with PK magic bytes are invalid and must be deleted before Gradle reads them
29+
for cache_dir in .gradle ~/.gradle; do
30+
if [ -d "$cache_dir" ]; then
31+
find "$cache_dir" -name "*.jar" | while IFS= read -r jar; do
32+
magic=$(head -c 2 "$jar" 2>/dev/null | od -A n -t x1 | tr -d ' \n')
33+
if [ "$magic" != "504b" ]; then
34+
echo "WARN: removing corrupt JAR (magic=${magic:-empty}): $jar"
35+
rm -f "$jar"
36+
fi
37+
done
38+
fi
39+
done
2940

3041
function onexit {
3142
mkdir -p "${REPO_ROOT}/test/${TARGET}/reports"
@@ -40,7 +51,7 @@ function onexit {
4051
trap onexit EXIT
4152

4253
set -x
43-
./gradlew -Pddprof_version="$(get_version)" -Pskip-cpp-tests :ddprof-lib:assembleReleaseJar --build-cache --stacktrace --info --no-watch-fs --no-daemon
54+
./gradlew -Pddprof_version="$(get_version)" -Pskip-cpp-tests :ddprof-lib:assembleReleaseJar --no-build-cache --stacktrace --info --no-watch-fs --no-daemon
4455

4556
mkdir -p "${REPO_ROOT}/libs"
4657
cp -r "${REPO_ROOT}/ddprof-lib/build/native/release/META-INF/native-libs/"* "${REPO_ROOT}/libs/"

0 commit comments

Comments
 (0)