From 8b5dcb5e0beb82766d587e38e53790ff2952bce7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Thu, 2 Jul 2015 16:12:29 +0200 Subject: [PATCH] add command line options to generate_batch_reports.sh --- scripts/generate_batch_reports.sh | 45 ++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/scripts/generate_batch_reports.sh b/scripts/generate_batch_reports.sh index 605839fc895..4bdd00fd97f 100755 --- a/scripts/generate_batch_reports.sh +++ b/scripts/generate_batch_reports.sh @@ -39,7 +39,24 @@ function createPrivateClone() { cd ${BUILD_DIR}${RELATIVE_PATH} } -DUMP_DIR="/tmp/batch_dumps" +function showHelp() { + echo "Usage: $0 -d DIR_PATH [ -l integer ] [ -h URL ] [ -u string ] [ -p string ]" + echo " -d : path to directory where batch report bumpds will be created" + echo " -l : number of commit in the past (optional: default is $HISTORY_LENGTH)" + echo " -h : URL of the SQ instance (optional: default is $SONAR_HOST)" + echo " -u : username to authentication on the SQ instance (optional: default is $SONAR_USER)" + echo " -p : password to authentication on the SQ instance (optional: default is $SONAR_USER)" +} + +function checkOptions() { + if [ "$DUMP_DIR" = "" ]; then + >&2 echo "-d option is mandatory" + showHelp + exit 1 + fi +} + +DUMP_DIR="" HISTORY_LENGTH=30 SONAR_HOST="http://localhost:9000" SONAR_USER="admin" @@ -48,6 +65,32 @@ SONAR_JDBC_URL="jdbc:postgresql://localhost:5432/sonar" SONAR_JDBC_USERNAME="sonar" SONAR_JDBC_PASSWORD="sonar" +while getopts ":d:l:h:u:p:" opt; do + case "$opt" in + d) DUMP_DIR=$OPTARG + ;; + l) HISTORY_LENGTH=$OPTARG + ;; + h) SONAR_HOST=$OPTARG + ;; + u) SONAR_USER=$OPTARG + ;; + p) SONAR_PASSWORD=$OPTARG + ;; + :) + >&2 echo "option $OPTARG requires an argument" + showHelp + exit 1 + ;; + \?) + >&2 echo "Unsupported option $OPTARG" + showHelp + exit 1 + ;; + esac +done +checkOptions + createPrivateClone # retrieve ${HISTORY_LENGTH} commits for the current directory -- 2.39.5