22
33set -euo pipefail
44
5- source cirrus-env BUILD
6- . set_maven_build_version " $BUILD_NUMBER "
7-
8- echo
9- echo " -- Build and analyze the project targeting a shadow SonarQube instance ---"
10-
11- mvn \
12- -Pcoverage \
13- -Dmaven.test.redirectTestOutputToFile=false \
14- -Dsonar.host.url=" ${SHADOW_SONAR_HOST_URL} " \
15- -Dsonar.token=" ${SHADOW_SONAR_TOKEN} " \
16- -Dsonar.organization=" ${SHADOW_ORGANIZATION} " \
17- -Dsonar.projectKey=" ${SHADOW_PROJECT_KEY} " \
18- -Dsonar.analysis.buildNumber=" ${BUILD_NUMBER} " \
19- -Dsonar.analysis.repository=" ${GITHUB_REPO} " \
20- --batch-mode --errors --show-version \
21- verify sonar:sonar
22-
23- echo
24- echo " -- Issue replication between two SonarQube instances ---"
25-
26- mkdir -p target/libs
27-
285# IRIS: Issue Replication for Sonarqube
29- IRIS_JAR_URL=" ${ARTIFACTORY_URL} /sonarsource-private-releases/com/sonarsource/iris/iris/\[RELEASE\]/iris-\[RELEASE\]-jar-with-dependencies.jar"
6+ export IRIS_JAR_URL=" ${ARTIFACTORY_URL} /sonarsource-private-releases/com/sonarsource/iris/iris/\[RELEASE\]/iris-\[RELEASE\]-jar-with-dependencies.jar"
7+ export IRIS_JAR_PATH=" target/libs/iris.jar"
8+
9+ function build_and_analyze_the_project() {
10+ echo
11+ echo " ===== Build and analyze the project targeting a shadow SonarQube instance"
12+ mvn \
13+ -Pcoverage \
14+ -Dmaven.test.redirectTestOutputToFile=false \
15+ -Dsonar.host.url=" ${SHADOW_SONAR_HOST_URL} " \
16+ -Dsonar.token=" ${SHADOW_SONAR_TOKEN} " \
17+ -Dsonar.organization=" ${SHADOW_ORGANIZATION} " \
18+ -Dsonar.projectKey=" ${SHADOW_PROJECT_KEY} " \
19+ -Dsonar.analysis.buildNumber=" ${BUILD_NUMBER} " \
20+ -Dsonar.analysis.repository=" ${GITHUB_REPO} " \
21+ --batch-mode --errors --show-version \
22+ verify sonar:sonar
23+ }
3024
31- curl --silent --fail-with-body --location --header " Authorization: Bearer ${ARTIFACTORY_PRIVATE_PASSWORD} " \
32- --output " target/libs/iris.jar" " ${IRIS_JAR_URL} "
25+ function download_iris() {
26+ echo
27+ echo " ===== Download ${IRIS_JAR_URL} "
28+ mkdir -p target/libs
29+ curl --silent --fail-with-body --location --header " Authorization: Bearer ${ARTIFACTORY_PRIVATE_PASSWORD} " \
30+ --output " ${IRIS_JAR_PATH} " " ${IRIS_JAR_URL} "
31+ }
3332
34- for DRY_RUN in true false ; do
33+ function run_iris() {
34+ local DRY_RUN=" $1 "
3535 java \
3636 -Diris.source.projectKey=" ${SONAR_PROJECT_KEY} " \
3737 -Diris.source.url=" ${SONAR_HOST_URL} " \
@@ -41,5 +41,30 @@ for DRY_RUN in true false; do
4141 -Diris.destination.url=" ${SHADOW_SONAR_HOST_URL} " \
4242 -Diris.destination.token=" ${SHADOW_SONAR_TOKEN} " \
4343 -Diris.dryrun=" ${DRY_RUN} " \
44- -jar " target/libs/iris.jar"
45- done
44+ -jar " ${IRIS_JAR_PATH} "
45+ }
46+
47+ function run_iris_with_and_without_dry_run() {
48+ echo
49+ echo " ===== Execute IRIS as dry-run"
50+ if run_iris true ; then
51+ echo " ===== Successful IRIS execution as dry-run"
52+ echo " ===== Execute IRIS for real"
53+ if run_iris false ; then
54+ echo " ===== Successful IRIS execution for real"
55+ return 0
56+ else
57+ echo " ===== Failed IRIS execution for real"
58+ return 1
59+ fi
60+ else
61+ echo " ===== Failed IRIS execution as dry-run"
62+ return 1
63+ fi
64+ }
65+
66+ source cirrus-env BUILD
67+ . set_maven_build_version " $BUILD_NUMBER "
68+ build_and_analyze_the_project
69+ download_iris
70+ run_iris_with_and_without_dry_run
0 commit comments