aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2015-07-02 12:13:04 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2015-07-02 16:14:34 +0200
commit5f9538c9a90d52cf29b7c58035fe2ff1ecb6375a (patch)
tree99b8392231c574664b4dbb286d9c5ab70796dfb8 /scripts
parent2e2c1fbdc5f17b9d8577c7582139d7427c398589 (diff)
downloadsonarqube-5f9538c9a90d52cf29b7c58035fe2ff1ecb6375a.tar.gz
sonarqube-5f9538c9a90d52cf29b7c58035fe2ff1ecb6375a.zip
add ability to dump batch report enabled by sonar.batch.dumpReportDir
batch report dump are saved in the directory specified by the property sonar.batch.dumpReportDir and the batch is NOT pushed to the server
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate_batch_reports.sh53
-rwxr-xr-xscripts/replay_batch.sh15
2 files changed, 68 insertions, 0 deletions
diff --git a/scripts/generate_batch_reports.sh b/scripts/generate_batch_reports.sh
new file mode 100755
index 00000000000..227d734b923
--- /dev/null
+++ b/scripts/generate_batch_reports.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+##############################
+#
+# Generates batch reports dumps of a specific project into a given dump repository
+# from the Git history of that project.
+#
+# This script runs the analysis of the project in the current directory of the N
+# last commits of the current project. N can be configured.
+#
+# Batch report dumps can be processed with the replay_batch.sh script
+#
+#
+##############################
+
+
+set -euo pipefail
+
+DUMP_DIR="/tmp/batch_dumps"
+HISTORY_LENGTH=30
+SONAR_HOST="http://localhost:9000"
+SONAR_USER="admin"
+SONAR_PASSWORD="admin"
+SONAR_JDBC_URL="jdbc:postgresql://localhost:5432/sonar"
+SONAR_JDBC_USERNAME="sonar"
+SONAR_JDBC_PASSWORD="sonar"
+
+function clean() {
+ git co $branch_name
+ git branch -D working_branch
+}
+
+trap "clean" EXIT
+
+# retrieve ${HISTORY_LENGTH} commits for the current directory
+git log -${HISTORY_LENGTH} --pretty=%h -- . | tac > /tmp/sha1s.txt
+
+branch_name=$(git symbolic-ref -q HEAD)
+branch_name=${branch_name##refs/heads/}
+branch_name=${branch_name:-HEAD}
+
+git co -b working_branch
+while read sha1; do
+ echo $sha1
+ git reset --hard $sha1
+ date=`git show -s --format=%ci | sed 's/ /T/' | sed 's/ //'`
+
+ echo ""
+ echo "======================== analyzing at $date ($sha1) ======================================="
+ $M2_HOME/bin/mvn sonar:sonar -Dsonar.host.url=$SONAR_HOST -Dsonar.login=$SONAR_USER -Dsonar.password=$SONAR_PASSWORD -Dsonar.analysis.mode=analysis -Dsonar.issuesReport.html.enable= -Dsonar.issuesReport.console.enable= -Dsonar.jdbc.url=$SONAR_JDBC_URL -Dsonar.jdbc.username=$SONAR_JDBC_USERNAME -Dsonar.jdbc.password=$SONAR_JDBC_PASSWORD -Dsonar.batch.dumpReportDir=$DUMP_DIR -Dsonar.projectDate=$date
+
+done < /tmp/sha1s.txt
+
diff --git a/scripts/replay_batch.sh b/scripts/replay_batch.sh
new file mode 100755
index 00000000000..c1bd9825016
--- /dev/null
+++ b/scripts/replay_batch.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+set -euo pipefail
+
+DUMP_DIR="/tmp/batch_dumps"
+SQ_ROOT_URL="http://localhost:9000"
+
+cd $DUMP_DIR
+for file in *.zip; do
+ base=${file%.zip}
+ url=$(cat ${base}.txt)
+ echo "base=$base, url=$url"
+
+ curl -u admin:admin -F report=@$DUMP_DIR/${base}.zip ${SQ_ROOT_URL}${url}
+done