Files
ci-image/entrypoint.sh
lucasdpt d8990636a3
All checks were successful
Release / release (push) Successful in 3m2s
feat: add MAVEN_SETTINGS_PATH
2025-11-24 12:45:04 +01:00

30 lines
957 B
Bash

#!/usr/bin/env bash
set -euo pipefail
# Entrypoint: write `MAVEN_SETTINGS` or decode `MAVEN_SETTINGS_BASE64`
# into ~/.m2/settings.xml (MAVEN_SETTINGS_BASE64 takes precedence),
# then exec the container command.
M2_DIR="${HOME:-/root}/.m2"
SETTINGS_FILE="$M2_DIR/settings.xml"
# Export the path to the settings.xml so downstream processes can read it
export MAVEN_SETTINGS_PATH="$SETTINGS_FILE"
if [[ -n "${MAVEN_SETTINGS_BASE64:-}" ]]; then
mkdir -p "$M2_DIR"
# Decode base64 content and write it. If decoding fails the script will error.
printf '%s' "$MAVEN_SETTINGS_BASE64" | base64 -d > "$M2_DIR/settings.xml"
chmod 644 "$M2_DIR/settings.xml" || true
elif [[ -n "${MAVEN_SETTINGS:-}" ]]; then
mkdir -p "$M2_DIR"
# Write the variable contents exactly as provided
printf '%s' "$MAVEN_SETTINGS" > "$M2_DIR/settings.xml"
chmod 644 "$M2_DIR/settings.xml" || true
fi
if [[ "$#" -eq 0 ]]; then
exec "$SHELL" || exec /bin/sh
fi
exec "$@"