diff --git a/hadoop-ozone/dev-support/checks/hadolint.sh b/hadoop-ozone/dev-support/checks/hadolint.sh index f811b4f4010f..63291a711942 100755 --- a/hadoop-ozone/dev-support/checks/hadolint.sh +++ b/hadoop-ozone/dev-support/checks/hadolint.sh @@ -17,25 +17,21 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" cd "$DIR/../../.." || exit 1 REPO_DIR="$DIR/../../.." -ERROR=0 +REPORT_DIR=${OUTPUT_DIR:-"$DIR/../../../target/hadolint"} +mkdir -p "$REPORT_DIR" +REPORT_FILE="$REPORT_DIR/summary.txt" +echo -n > "$REPORT_FILE" - -for Dockerfile in $(find "$REPO_DIR/hadoop-ozone" "$REPO_DIR/hadoop-hdds" -name Dockerfile | sort); do - echo "Checking $Dockerfile" - - result=$( hadolint $Dockerfile ) - if [ ! -z "$result" ] - then - echo "$result" - echo "" - ERROR=1 - fi +for Dockerfile in $(find hadoop-ozone hadoop-hdds -name Dockerfile | sort); do + hadolint $Dockerfile | tee -a "$REPORT_FILE" done -if [ "$ERROR" = 1 ] +wc -l "$REPORT_FILE" | awk '{print $1}'> "$REPORT_DIR/failures" + +if [ -s "${REPORT_FILE}" ] then - echo "" - echo "" - echo "Hadolint errors were found. Exit code: 1." + echo "" | tee -a "$REPORT_FILE" + echo "" | tee -a "$REPORT_FILE" + echo "Hadolint errors were found. Exit code: 1." | tee -a "$REPORT_FILE" exit 1 fi