ccollins
(Christian Collins)
June 11, 2024, 12:46pm
1
Template for a good new topic, formatted with Markdown :
ALM used: ADO
CI system used: Azure DevOps
Scanner command used when applicable SonarCLoudPrepare@2
Languages of the repository: mixed
Steps to reproduce
Scanning the codebase hits the same old Java Ruby errors:
##[error]12:38:46.154 ERROR [stderr] 2024-06-11T12:38:46.120Z [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem
12:38:46.155 ERROR [stderr] Pass ‘–add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED’ to enable.
But how is this passed in ADO?
I have tried an extraProperties field:
cliProjectName: *blah*
cliSources: '.'
cliVersion: '6.0.0.4432'
extraProperties: |
sonar.scanner.opts='--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED'
That didn’t work. Forcing an env variable into it doesn’t work:
task: Bash@3
displayName: ‘Set env vars’
inputs:
targetType: ‘inline’
script: |
set -e
export SONAR_SCANNER_OPTS=‘–add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED’
What am I missing?
Colin
(Colin)
June 12, 2024, 7:07am
2
Hey there.
I think you have to set the SONAR_SCANNER_OPTS
variable at the pipeline level, rather than the task.
ok. looks like its working if we add the variable in the pipeline level instead of task level. but I need to check the analysis report generated by both Java versions.
ccollins
(Christian Collins)
June 12, 2024, 9:40am
3
What does that actually mean? It’s an ADO Task. I can understand the GitHub actions stuff, but that’s not relevant,
Colin
(Colin)
June 12, 2024, 2:19pm
4
You can set pipeline variables in Azure DevOps as documented here .
ccollins
(Christian Collins)
June 12, 2024, 3:53pm
5
Yeah, still not having any effect:
variables:
SONAR_SCANNER_OPTS: '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED'
pool:
vmImage: ubuntu-latest
14:55:16.981 INFO SONAR_SCANNER_OPTS=–add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED
…
14:58:30.351 ERROR [stderr] at org.sonar.scanner.bootstrap.ScannerMain.main(ScannerMain.java:38)
##[error]14:58:30.355 ERROR [stderr] 2024-06-12T14:58:30.309Z [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem
14:58:30.355 ERROR [stderr] Pass '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED' to enable.
ccollins
(Christian Collins)
June 12, 2024, 3:55pm
6
I also tried sticking in an env variable with Bash
Colin
(Colin)
June 14, 2024, 2:55pm
7
Last shot before I shoot this over to our devs – can you try the JDK_JAVA_OPTIONS
environment variable?
ccollins
(Christian Collins)
June 14, 2024, 3:08pm
8
So on the newer version (6) it says to use SONAR_SCANNER_JAVA_OPTS, and when I put that in as an extra property , it complains that it isn’t java:
##[error]12:23:04.870 ERROR [stderr] Error: Could not find or load main class '–add-opens
Colin
(Colin)
June 17, 2024, 4:25pm
9
Where does it say that? v6 is new, I hope I didn’t miss a memo.
Seems like an issue with spaces. Wrapping in quotation marks might help.
ccollins
(Christian Collins)
June 18, 2024, 9:10am
10
ccollins
(Christian Collins)
June 18, 2024, 9:29am
11
Although in here, there seems to be a mix of unix quotes and curly quotes: [SonarScanner CLI & SonarCloud (sonarsource.com )]Analysis Parameters & SonarCloud
ccollins
(Christian Collins)
June 18, 2024, 10:35am
13
##[error]10:34:37.029 ERROR [stderr] Error: Could not find or load main class "–add-opens
This is with double quotes
cliVersion: '6.0.0.4432'
extraProperties: |
sonar.scanner.javaOpts="--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED"
sonar.sourceEncoding=UTF-8
sonar.exclusions=**/*appsettings*.json
Colin
(Colin)
June 18, 2024, 12:13pm
14
Hey!
Thanks. This new parameter was news to me.
It looks like we have a bug, and didn’t account for java options that look like this.
@SerializedName("level")
private String level;
@SerializedName("message")
private String message;
@SerializedName("stacktrace")
private String stacktrace;
}
private List<String> buildArgs(Map<String, String> properties) {
List<String> args = new ArrayList<>();
String javaOpts = properties.get(ScannerProperties.SCANNER_JAVA_OPTS);
if (javaOpts != null) {
args.addAll(split(javaOpts));
}
args.add("-jar");
args.add(scannerEngineJar.getPathInCache().toAbsolutePath().toString());
return args;
}
private static List<String> split(String value) {
return Arrays.stream(value.split("\\s+"))
You can probably revert to v1 of the tasks (or set the version in v2 to 5.0.1.3006), and then be able to use SONAR_SCANNER_OPTS
again. I’ll flag this for attention.
ccollins
(Christian Collins)
June 18, 2024, 2:49pm
16
This has worked for me:
variables:
SONAR_SCANNER_OPTS: '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED'
steps:
- task: SonarCloudPrepare@2
inputs:
SonarCloud: 'MySCLink'
organization: 'org'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: 'key'
cliProjectName: 'prod'
cliSources: '.'
cliVersion: '5.0.1.3006'
1 Like
system
(system)
Closed
June 27, 2024, 12:17pm
18
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.