Skip to content

Commit 9e0cb88

Browse files
committed
JAVASE-14 Unify Platform Dogfooding of sonar-java-symbolic-execution
1 parent 2963244 commit 9e0cb88

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

.cirrus.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,35 @@ build_task:
5555
- regular_mvn_build_deploy_analyze
5656
cleanup_before_cache_script: cleanup_maven_repository
5757

58+
sonar_shadow_scan_and_issue_replication_task:
59+
depends_on:
60+
- build
61+
# Only run when triggered by the cirrus-ci cron job named "nightly"
62+
only_if: $CIRRUS_CRON == "nightly"
63+
eks_container:
64+
<<: *CONTAINER_DEFINITION
65+
cpu: 4
66+
memory: 4G
67+
env:
68+
SONAR_PROJECT_KEY: "org.sonarsource.java:sonar-java-symbolic-execution"
69+
SHADOW_ORGANIZATION: "sonarsource"
70+
SHADOW_PROJECT_KEY: "SonarSource_sonar-java-symbolic-execution"
71+
# to replicate issue states from next
72+
SONAR_TOKEN: VAULT[development/kv/data/next data.token]
73+
SONAR_HOST_URL: https://next.sonarqube.com/sonarqube
74+
matrix:
75+
- name: "sonarcloud.io"
76+
SHADOW_SONAR_TOKEN: VAULT[development/kv/data/sonarcloud data.token]
77+
SHADOW_SONAR_HOST_URL: "https://sonarcloud.io"
78+
- name: "sonarqube.us"
79+
SHADOW_SONAR_TOKEN: VAULT[development/kv/data/sonarqube-us data.token]
80+
SHADOW_SONAR_HOST_URL: "https://sonarqube.us"
81+
maven_cache:
82+
folder: ${CIRRUS_WORKING_DIR}/.m2/repository
83+
build_and_shadow_scan_script:
84+
- ./shadow-scan-and-issue-replication.sh
85+
cleanup_before_cache_script: cleanup_maven_repository
86+
5887
ws_scan_task:
5988
<<: *ONLY_SONARSOURCE_QA
6089
eks_container:
@@ -121,6 +150,7 @@ ruling_task:
121150
promote_task:
122151
depends_on:
123152
- build
153+
- sonar_shadow_scan_and_issue_replication
124154
- ws_scan
125155
- ruling
126156
<<: *ONLY_SONARSOURCE_QA
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# IRIS: Issue Replication for Sonarqube
6+
IRIS_JAR_URL="${ARTIFACTORY_URL}/sonarsource-private-releases/com/sonarsource/iris/iris/\[RELEASE\]/iris-\[RELEASE\]-jar-with-dependencies.jar"
7+
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+
}
24+
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+
}
32+
33+
function run_iris() {
34+
local DRY_RUN="$1"
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 "${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)