Skip to content

Commit 4ef33a5

Browse files
committed
chore: check table-test jar downloaded through mirror
1 parent fd65c0a commit 4ef33a5

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

.gitlab-ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,61 @@ default:
218218
# Check and fail early if maven central credentials are incorrect. When a new token is generated
219219
# on the central publisher portal, it invalidates the old one. This check prevents going further.
220220
# See https://datadoghq.atlassian.net/wiki/x/Oog5OgE
221+
check-maven-proxy-artifact:
222+
image: ${BUILDER_IMAGE_REPO}:${BUILDER_IMAGE_VERSION_PREFIX}base
223+
stage: .pre
224+
rules:
225+
- when: on_success
226+
script:
227+
- |
228+
check_jar() {
229+
local label="$1" file="$2"
230+
echo "--- Checking: ${label} ---"
231+
local size
232+
size=$(wc -c < "${file}")
233+
echo "File size: ${size} bytes"
234+
if [ "${size}" -eq 0 ]; then
235+
echo "ERROR: file is empty"
236+
return 1
237+
fi
238+
local magic
239+
magic=$(head -c 4 "${file}" | od -A n -t x1 | tr -d ' \n')
240+
local type
241+
type=$(file "${file}")
242+
echo "File magic bytes: ${magic} | file: ${type}"
243+
if [ "${magic}" = "504b0304" ]; then
244+
echo "OK: valid JAR/ZIP magic bytes"
245+
else
246+
echo "ERROR: not a valid JAR/ZIP file (expected 504b0304, got ${magic})"
247+
if echo "${type}" | grep -qi "xml\|html\|text"; then
248+
echo "--- File content ---"
249+
cat "${file}"
250+
echo "--- End of content ---"
251+
fi
252+
return 1
253+
fi
254+
}
255+
256+
ARTIFACT_PATH="org/tabletest/tabletest-junit/1.2.0/tabletest-junit-1.2.0.jar"
257+
RESULT=0
258+
259+
echo "=== Downloading from Magic Mirror proxy ==="
260+
curl --fail --location --silent --show-error --output tabletest-junit-proxy.jar "${MAVEN_REPOSITORY_PROXY}${ARTIFACT_PATH}" \
261+
&& check_jar "proxy" tabletest-junit-proxy.jar \
262+
|| RESULT=1
263+
264+
echo "=== Downloading from Maven Central ==="
265+
curl --fail --location --silent --show-error --output tabletest-junit-central.jar "https://repo1.maven.org/maven2/${ARTIFACT_PATH}" \
266+
&& check_jar "central" tabletest-junit-central.jar \
267+
|| RESULT=1
268+
269+
exit $RESULT
270+
artifacts:
271+
when: always
272+
paths:
273+
- tabletest-junit-proxy.jar
274+
- tabletest-junit-central.jar
275+
221276
maven-central-pre-release-check:
222277
image: ${BUILDER_IMAGE_REPO}:${BUILDER_IMAGE_VERSION_PREFIX}base
223278
stage: .pre

0 commit comments

Comments
 (0)