Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 884b794

Browse files
committedSep 24, 2024·
SQSCANGHA-42 Update Scanner CLI Docker to 11.1
1 parent f885e52 commit 884b794

File tree

3 files changed

+90
-15
lines changed

3 files changed

+90
-15
lines changed
 

‎.github/workflows/qa.yml

+73-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ on:
88
types: [opened, synchronize, reopened]
99

1010
jobs:
11+
noInputsTest:
12+
name: >
13+
No inputs
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
- name: Run action with args
20+
uses: ./
21+
env:
22+
SONAR_HOST_URL: http://not_actually_used
23+
SONAR_SCANNER_JSON_PARAMS: '{"sonar.scanner.internal.dumpToFile": "./output.properties"}'
24+
- name: Assert
25+
run: |
26+
./test/assertFileContains ./output.properties "sonar.projectBaseDir=."
1127
argsInputTest:
1228
name: >
1329
'args' input
@@ -19,9 +35,10 @@ jobs:
1935
- name: Run action with args
2036
uses: ./
2137
with:
22-
args: -Dsonar.someArg=aValue -Dsonar.scanner.dumpToFile=./output.properties
38+
args: -Dsonar.someArg=aValue
2339
env:
2440
SONAR_HOST_URL: http://not_actually_used
41+
SONAR_SCANNER_JSON_PARAMS: '{"sonar.scanner.internal.dumpToFile": "./output.properties"}'
2542
- name: Assert
2643
run: |
2744
./test/assertFileContains ./output.properties "sonar.someArg=aValue"
@@ -37,10 +54,10 @@ jobs:
3754
- name: Run action with projectBaseDir
3855
uses: ./
3956
with:
40-
args: -Dsonar.scanner.dumpToFile=./output.properties
4157
projectBaseDir: ./baseDir
4258
env:
4359
SONAR_HOST_URL: http://not_actually_used
60+
SONAR_SCANNER_JSON_PARAMS: '{"sonar.scanner.internal.dumpToFile": "./output.properties"}'
4461
- name: Assert
4562
run: |
4663
./test/assertFileContains ./output.properties "sonar.projectBaseDir=.*/baseDir"
@@ -58,9 +75,9 @@ jobs:
5875
continue-on-error: true
5976
env:
6077
SONAR_HOST_URL: http://not_actually_used
78+
SONAR_SCANNER_JSON_PARAMS: '{"sonar.scanner.internal.dumpToFile": "./output.properties"}'
6179
with:
6280
projectBaseDir: ./test/gradle-project
63-
args: -Dsonar.scanner.dumpToFile=./output.properties
6481
- name: Assert
6582
run: |
6683
./test/assertFileExists ./output.properties
@@ -78,9 +95,9 @@ jobs:
7895
continue-on-error: true
7996
env:
8097
SONAR_HOST_URL: http://not_actually_used
98+
SONAR_SCANNER_JSON_PARAMS: '{"sonar.scanner.internal.dumpToFile": "./output.properties"}'
8199
with:
82100
projectBaseDir: ./test/gradle-project
83-
args: -Dsonar.scanner.dumpToFile=./output.properties
84101
- name: Assert
85102
run: |
86103
./test/assertFileExists ./output.properties
@@ -98,9 +115,9 @@ jobs:
98115
continue-on-error: true
99116
env:
100117
SONAR_HOST_URL: http://not_actually_used
118+
SONAR_SCANNER_JSON_PARAMS: '{"sonar.scanner.internal.dumpToFile": "./output.properties"}'
101119
with:
102120
projectBaseDir: ./test/maven-project
103-
args: -Dsonar.scanner.dumpToFile=./output.properties
104121
- name: Assert
105122
run: |
106123
./test/assertFileExists ./output.properties
@@ -145,11 +162,10 @@ jobs:
145162
token: ${{ secrets.GITHUB_TOKEN }}
146163
- name: Run action with debug mode
147164
uses: ./
148-
with:
149-
args: -Dsonar.scanner.dumpToFile=./output.properties
150165
env:
151166
RUNNER_DEBUG: 1
152167
SONAR_HOST_URL: http://not_actually_used
168+
SONAR_SCANNER_JSON_PARAMS: '{"sonar.scanner.internal.dumpToFile": "./output.properties"}'
153169
- name: Assert
154170
run: |
155171
./test/assertFileContains ./output.properties "sonar.verbose=true"
@@ -190,3 +206,53 @@ jobs:
190206
- name: Assert
191207
run: |
192208
./test/assertFileExists ./test/example-project/.scannerwork/report-task.txt
209+
useSslCertificate:
210+
name: >
211+
'SONAR_ROOT_CERT' is converted to truststore
212+
runs-on: ubuntu-latest
213+
steps:
214+
- uses: actions/checkout@v4
215+
with:
216+
token: ${{ secrets.GITHUB_TOKEN }}
217+
- name: Run action with SSL certificate
218+
uses: ./
219+
env:
220+
SONAR_ROOT_CERT: |
221+
-----BEGIN CERTIFICATE-----
222+
MIIFtjCCA56gAwIBAgIULroxFuPWyNOiQtAVPS/XFFMXp6owDQYJKoZIhvcNAQEL
223+
BQAwXDELMAkGA1UEBhMCQ0gxDzANBgNVBAgMBkdlbmV2YTEPMA0GA1UEBwwGR2Vu
224+
ZXZhMRcwFQYDVQQKDA5Tb25hclNvdXJjZSBTQTESMBAGA1UEAwwJbG9jYWxob3N0
225+
MB4XDTI0MDQxNjA4NDUyMVoXDTM0MDQxNDA4NDUyMVowXDELMAkGA1UEBhMCQ0gx
226+
DzANBgNVBAgMBkdlbmV2YTEPMA0GA1UEBwwGR2VuZXZhMRcwFQYDVQQKDA5Tb25h
227+
clNvdXJjZSBTQTESMBAGA1UEAwwJbG9jYWxob3N0MIICIjANBgkqhkiG9w0BAQEF
228+
AAOCAg8AMIICCgKCAgEArRRQF25E5NCgXdoEBU2SWyAoyOWMGVT1Ioltnr3sJP6L
229+
MjjfozK5YgaRn504291lwlG+k6tvzTSR9HB8q3ITa8AdnwMiL7jzbveYKWIlLQ7k
230+
dHKXWbiaIjTaZCyfnWUlDFIuR7BHwOXVwyLrBQfhoyDVaaoyowQEsUro3okIR/kB
231+
sqM+KH8bcdl06DMMppZ8Qy1DYvPodhnNRyOSSpfbIoodE1fju+5U0OKzvGIc9WpG
232+
5pKIysaW3whOa/ieb02SXrgoiHnYPpmmGzm4u/Wn8jGwhYQJSQT10yjMacGHwmBE
233+
q7FUr854cVd+eend056P6pwUukdNeVHCFjYRkmWCNzIxV+sS9PPtDs77/bLFIItr
234+
nBMHVsId38tPoru/z1S1p2dzCX3Nq09aJFF/vH2u9Sg5aerHJ7xnRroR1jIrAZtc
235+
jBkJHEiTlG+WaavP4j6oym+lvHvgHHL3Qwhh8emg0JiLYExVV7ma70aRDh8yoQtS
236+
zAUDMVfhVPKd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
Fct6d1S08JAosVnZcP2P7Yz+TbmDRtsqCgk=
253+
-----END CERTIFICATE-----
254+
SONAR_HOST_URL: http://not_actually_used
255+
SONAR_SCANNER_JSON_PARAMS: '{"sonar.scanner.internal.dumpToFile": "./output.properties"}'
256+
- name: Assert
257+
run: |
258+
./test/assertFileContains ./output.properties "sonar.scanner.truststorePassword=changeit"

‎Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM sonarsource/sonar-scanner-cli:10.0
1+
FROM sonarsource/sonar-scanner-cli:11.1
22

3-
LABEL version="2.1.0" \
3+
LABEL version="3.0.0" \
44
repository="https://github.com/sonarsource/sonarqube-scan-action" \
55
homepage="https://github.com/sonarsource/sonarqube-scan-action" \
66
maintainer="SonarSource" \

‎entrypoint.sh

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22

3-
set -e
3+
set -eo pipefail
4+
5+
declare -a args=()
46

57
if [[ -z "${SONAR_TOKEN}" ]]; then
68
echo "============================ WARNING ============================"
@@ -9,10 +11,15 @@ if [[ -z "${SONAR_TOKEN}" ]]; then
911
fi
1012

1113
if [[ -n "${SONAR_ROOT_CERT}" ]]; then
12-
echo "Adding custom root certificate to java certificate store"
14+
echo "Adding custom root certificate to the scanner truststore"
1315
rm -f /tmp/tmpcert.pem
1416
echo "${SONAR_ROOT_CERT}" > /tmp/tmpcert.pem
15-
keytool -keystore /etc/ssl/certs/java/cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias sonarqube -file /tmp/tmpcert.pem
17+
# we can't use the default "sonar" password as keytool requires a password with at least 6 characters
18+
args+=("-Dsonar.scanner.truststorePassword=changeit")
19+
mkdir -p $SONAR_USER_HOME/ssl
20+
keytool -storetype PKCS12 -keystore $SONAR_USER_HOME/ssl/truststore.p12 -storepass changeit -noprompt -trustcacerts -importcert -alias sonarqube -file /tmp/tmpcert.pem
21+
# for older SQ versions < 10.6
22+
export SONAR_SCANNER_OPTS="${SONAR_SCANNER_OPTS:-} -Djavax.net.ssl.trustStore=$SONAR_USER_HOME/ssl/truststore.p12 -Djavax.net.ssl.trustStorePassword=changeit"
1623
fi
1724

1825
if [[ -f "${INPUT_PROJECTBASEDIR%/}/pom.xml" ]]; then
@@ -25,12 +32,14 @@ if [[ -f "${INPUT_PROJECTBASEDIR%/}/build.gradle" || -f "${INPUT_PROJECTBASEDIR
2532
to get more accurate results."
2633
fi
2734

28-
debug_flag=''
35+
2936
if [[ "$RUNNER_DEBUG" == '1' ]]; then
30-
debug_flag='--debug'
37+
args+=("--debug")
3138
fi
3239

3340
unset JAVA_HOME
3441

35-
sonar-scanner $debug_flag -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} ${INPUT_ARGS}
42+
args+=("-Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR}")
43+
44+
sonar-scanner "${args[@]}" ${INPUT_ARGS}
3645

0 commit comments

Comments
 (0)
Please sign in to comment.