Skip to content

Commit 1766ca0

Browse files
committed
SONARXML-252 Unify Platform Dogfooding of sonar-xml
1 parent 29fc3da commit 1766ca0

File tree

2 files changed

+77
-3
lines changed

2 files changed

+77
-3
lines changed

.cirrus.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ 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]
20+
SONAR_PROJECT_KEY: "org.sonarsource.xml:xml"
21+
1722
# Use bash (instead of sh on linux or cmd.exe on windows)
1823
CIRRUS_SHELL: bash
1924

@@ -50,9 +55,6 @@ build_task:
5055
cpu: 2
5156
memory: 2G
5257
env:
53-
# analysis on next
54-
SONAR_TOKEN: VAULT[development/kv/data/next data.token]
55-
SONAR_HOST_URL: https://next.sonarqube.com/sonarqube
5658
SIGN_KEY: VAULT[development/kv/data/sign data.key]
5759
PGP_PASSPHRASE: VAULT[development/kv/data/sign data.passphrase]
5860
#allow deployment of pull request artifacts to repox
@@ -65,6 +67,32 @@ build_task:
6567
- regular_mvn_build_deploy_analyze
6668
cleanup_before_cache_script: cleanup_maven_repository
6769

70+
sonar_shadow_scan_and_issue_replication_task:
71+
depends_on:
72+
- build
73+
# Only run when triggered by the cirrus-ci cron job named "nightly"
74+
only_if: $CIRRUS_CRON == "nightly"
75+
eks_container:
76+
<<: *CONTAINER_DEFINITION
77+
cpu: 2
78+
memory: 2G
79+
env:
80+
SHADOW_ORGANIZATION: "sonarsource"
81+
SHADOW_PROJECT_KEY: "SonarSource_sonar-xml"
82+
matrix:
83+
- name: "sonarcloud.io"
84+
SHADOW_SONAR_TOKEN: VAULT[development/kv/data/sonarcloud data.token]
85+
SHADOW_SONAR_HOST_URL: "https://sonarcloud.io"
86+
- name: "sonarqube.us"
87+
SHADOW_SONAR_TOKEN: VAULT[development/kv/data/sonarqube-us data.token]
88+
SHADOW_SONAR_HOST_URL: "https://sonarqube.us"
89+
maven_cache:
90+
folder: ${CIRRUS_WORKING_DIR}/.m2/repository
91+
build_script:
92+
- *log_develocity_url_script
93+
- ./shadow-scan-and-issue-replication.sh
94+
cleanup_before_cache_script: cleanup_maven_repository
95+
6896
ws_scan_task:
6997
depends_on:
7098
- build
@@ -159,6 +187,7 @@ ruling_win_task:
159187
promote_task:
160188
depends_on:
161189
- build
190+
- sonar_shadow_scan_and_issue_replication
162191
- build_win
163192
- ruling
164193
- ruling_win
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
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+
28+
# 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"
30+
31+
curl --silent --fail-with-body --location --header "Authorization: Bearer ${ARTIFACTORY_PRIVATE_PASSWORD}" \
32+
--output "target/libs/iris.jar" "${IRIS_JAR_URL}"
33+
34+
for DRY_RUN in true false; do
35+
java \
36+
-Diris.source.projectKey="${SONAR_PROJECT_KEY}" \
37+
-Diris.source.url="${SONAR_HOST_URL}" \
38+
-Diris.source.token="${SONAR_TOKEN}" \
39+
-Diris.destination.projectKey="${SHADOW_PROJECT_KEY}" \
40+
-Diris.destination.organization="${SHADOW_ORGANIZATION}" \
41+
-Diris.destination.url="${SHADOW_SONAR_HOST_URL}" \
42+
-Diris.destination.token="${SHADOW_SONAR_TOKEN}" \
43+
-Diris.dryrun="${DRY_RUN}" \
44+
-jar "target/libs/iris.jar"
45+
done

0 commit comments

Comments
 (0)