Skip to content

Commit 0cf142b

Browse files
committed
Fix from review
1 parent 1766ca0 commit 0cf142b

File tree

2 files changed

+60
-33
lines changed

2 files changed

+60
-33
lines changed

.cirrus.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ env:
1414
ARTIFACTORY_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader access_token]
1515
DEVELOCITY_TOKEN: VAULT[development/kv/data/develocity data.token]
1616
DEVELOCITY_ACCESS_KEY: develocity.sonar.build=${DEVELOCITY_TOKEN}
17-
# analysis on next
18-
SONAR_HOST_URL: "https://next.sonarqube.com/sonarqube"
19-
SONAR_TOKEN: VAULT[development/kv/data/next data.token]
2017
SONAR_PROJECT_KEY: "org.sonarsource.xml:xml"
21-
2218
# Use bash (instead of sh on linux or cmd.exe on windows)
2319
CIRRUS_SHELL: bash
2420

@@ -55,6 +51,9 @@ build_task:
5551
cpu: 2
5652
memory: 2G
5753
env:
54+
# analysis on next
55+
SONAR_TOKEN: VAULT[development/kv/data/next data.token]
56+
SONAR_HOST_URL: https://next.sonarqube.com/sonarqube
5857
SIGN_KEY: VAULT[development/kv/data/sign data.key]
5958
PGP_PASSPHRASE: VAULT[development/kv/data/sign data.passphrase]
6059
#allow deployment of pull request artifacts to repox
@@ -79,6 +78,9 @@ sonar_shadow_scan_and_issue_replication_task:
7978
env:
8079
SHADOW_ORGANIZATION: "sonarsource"
8180
SHADOW_PROJECT_KEY: "SonarSource_sonar-xml"
81+
# to replicate issue states from next
82+
SONAR_TOKEN: VAULT[development/kv/data/next data.token]
83+
SONAR_HOST_URL: https://next.sonarqube.com/sonarqube
8284
matrix:
8385
- name: "sonarcloud.io"
8486
SHADOW_SONAR_TOKEN: VAULT[development/kv/data/sonarcloud data.token]

shadow-scan-and-issue-replication.sh

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@
22

33
set -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

Comments
 (0)