Skip to content

Commit 7a58b7b

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

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

.cirrus.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,36 @@ 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+
# TODO 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+
- source cirrus-env BUILD
85+
- ./shadow-scan-and-issue-replication.sh
86+
cleanup_before_cache_script: cleanup_maven_repository
87+
5888
ws_scan_task:
5989
<<: *ONLY_SONARSOURCE_QA
6090
eks_container:
@@ -121,6 +151,7 @@ ruling_task:
121151
promote_task:
122152
depends_on:
123153
- build
154+
- sonar_shadow_scan_and_issue_replication
124155
- ws_scan
125156
- ruling
126157
<<: *ONLY_SONARSOURCE_QA
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
local BUILD_CMD
13+
if [[ -e "settings.gradle" ]]; then
14+
BUILD_CMD="./gradlew --info --stacktrace --console plain build sonar"
15+
else
16+
source set_maven_build_version "$BUILD_NUMBER"
17+
BUILD_CMD="mvn -Pcoverage -Dmaven.test.redirectTestOutputToFile=false --batch-mode --errors --show-version verify sonar:sonar"
18+
fi
19+
${BUILD_CMD} \
20+
-DbuildNumber="${BUILD_NUMBER}" \
21+
-Dsonar.host.url="${SHADOW_SONAR_HOST_URL}" \
22+
-Dsonar.token="${SHADOW_SONAR_TOKEN}" \
23+
-Dsonar.organization="${SHADOW_ORGANIZATION}" \
24+
-Dsonar.projectKey="${SHADOW_PROJECT_KEY}" \
25+
-Dsonar.analysis.buildNumber="${BUILD_NUMBER}" \
26+
-Dsonar.analysis.repository="${GITHUB_REPO}" \
27+
"$@"
28+
}
29+
30+
function download_iris() {
31+
echo
32+
echo "===== Download ${IRIS_JAR_URL}"
33+
mkdir -p target/libs
34+
curl --silent --fail-with-body --location --header "Authorization: Bearer ${ARTIFACTORY_PRIVATE_PASSWORD}" \
35+
--output "${IRIS_JAR_PATH}" "${IRIS_JAR_URL}"
36+
}
37+
38+
function run_iris() {
39+
local DRY_RUN="$1"
40+
java \
41+
-Diris.source.projectKey="${SONAR_PROJECT_KEY}" \
42+
-Diris.source.url="${SONAR_HOST_URL}" \
43+
-Diris.source.token="${SONAR_TOKEN}" \
44+
-Diris.destination.projectKey="${SHADOW_PROJECT_KEY}" \
45+
-Diris.destination.organization="${SHADOW_ORGANIZATION}" \
46+
-Diris.destination.url="${SHADOW_SONAR_HOST_URL}" \
47+
-Diris.destination.token="${SHADOW_SONAR_TOKEN}" \
48+
-Diris.dryrun="${DRY_RUN}" \
49+
-jar "${IRIS_JAR_PATH}"
50+
}
51+
52+
function run_iris_with_and_without_dry_run() {
53+
echo
54+
echo "===== Execute IRIS as dry-run"
55+
if run_iris true; then
56+
echo "===== Successful IRIS execution as dry-run"
57+
echo "===== Execute IRIS for real"
58+
if run_iris false; then
59+
echo "===== Successful IRIS execution for real"
60+
return 0
61+
else
62+
echo "===== Failed IRIS execution for real"
63+
return 1
64+
fi
65+
else
66+
echo "===== Failed IRIS execution as dry-run"
67+
return 1
68+
fi
69+
}
70+
71+
build_and_analyze_the_project "$@"
72+
download_iris
73+
run_iris_with_and_without_dry_run

0 commit comments

Comments
 (0)