Skip to content

Commit dfe01c3

Browse files
committed
SONARSCALA-66 Unify Platform Dogfooding of sonar-scala
1 parent 81d679f commit dfe01c3

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

.cirrus.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,36 @@ build_task:
6767
heap_dump_artifacts:
6868
path: "*.hprof"
6969

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+
# TODO only_if: $CIRRUS_CRON == "nightly"
75+
eks_container:
76+
<<: *CONTAINER_DEFINITION
77+
cpu: 8
78+
memory: 4G
79+
env:
80+
SONAR_PROJECT_KEY: "SonarSource_sonar-scala"
81+
SHADOW_ORGANIZATION: "sonarsource"
82+
SHADOW_PROJECT_KEY: "SonarSource_sonar-scala"
83+
# to replicate issue states from next
84+
SONAR_TOKEN: VAULT[development/kv/data/next data.token]
85+
SONAR_HOST_URL: https://next.sonarqube.com/sonarqube
86+
matrix:
87+
- name: "sonarcloud.io"
88+
SHADOW_SONAR_TOKEN: VAULT[development/kv/data/sonarcloud data.token]
89+
SHADOW_SONAR_HOST_URL: "https://sonarcloud.io"
90+
- name: "sonarqube.us"
91+
SHADOW_SONAR_TOKEN: VAULT[development/kv/data/sonarqube-us data.token]
92+
SHADOW_SONAR_HOST_URL: "https://sonarqube.us"
93+
<<: *SETUP_GRADLE_CACHE
94+
build_script:
95+
- *log_develocity_url_script
96+
- source cirrus-env BUILD
97+
- source set_gradle_build_version
98+
- ./shadow-scan-and-issue-replication.sh
99+
70100
mend_task:
71101
depends_on:
72102
- build
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
./gradlew "$@" \
13+
-DbuildNumber="${BUILD_NUMBER}" \
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+
--info --stacktrace --console plain \
21+
build sonar
22+
}
23+
24+
function download_iris() {
25+
echo
26+
echo "===== Download ${IRIS_JAR_URL}"
27+
mkdir -p target/libs
28+
curl --silent --fail-with-body --location --header "Authorization: Bearer ${ARTIFACTORY_PRIVATE_PASSWORD}" \
29+
--output "${IRIS_JAR_PATH}" "${IRIS_JAR_URL}"
30+
}
31+
32+
function run_iris() {
33+
local DRY_RUN="$1"
34+
java \
35+
-Diris.source.projectKey="${SONAR_PROJECT_KEY}" \
36+
-Diris.source.url="${SONAR_HOST_URL}" \
37+
-Diris.source.token="${SONAR_TOKEN}" \
38+
-Diris.destination.projectKey="${SHADOW_PROJECT_KEY}" \
39+
-Diris.destination.organization="${SHADOW_ORGANIZATION}" \
40+
-Diris.destination.url="${SHADOW_SONAR_HOST_URL}" \
41+
-Diris.destination.token="${SHADOW_SONAR_TOKEN}" \
42+
-Diris.dryrun="${DRY_RUN}" \
43+
-jar "${IRIS_JAR_PATH}"
44+
}
45+
46+
function run_iris_with_and_without_dry_run() {
47+
echo
48+
echo "===== Execute IRIS as dry-run"
49+
if run_iris true; then
50+
echo "===== Successful IRIS execution as dry-run"
51+
echo "===== Execute IRIS for real"
52+
if run_iris false; then
53+
echo "===== Successful IRIS execution for real"
54+
return 0
55+
else
56+
echo "===== Failed IRIS execution for real"
57+
return 1
58+
fi
59+
else
60+
echo "===== Failed IRIS execution as dry-run"
61+
return 1
62+
fi
63+
}
64+
65+
build_and_analyze_the_project "$@"
66+
download_iris
67+
run_iris_with_and_without_dry_run

0 commit comments

Comments
 (0)