I want to analyze GC logs. I’m using the sonarqube-scanner via NPM (4.2.1) and passing sonar.scanner.javaOpts. An example value is sonar.scanner.javaOpts=-XX:+PrintFlagsFinal -Xlog:gc*:file=gc.log.
Unfortunately, sonar-scanner-npm splits up the CLI arguments incorrectly and has trouble when there is an additional = in the value. In debug mode (-X) the bootstrapper tells me the passed values and the one for the Java options ends up as 'sonar.scanner.javaOpts': '-XX:+PrintFlagsFinal -Xlog:gc*:file'.
which splits the argument value further if there is a = we could do
// Parse CLI args (eg: -Dsonar.token=xxx)
for (const arg of define) {
const [key, ...rest] = arg.split('=');
const value = rest.join('=');
properties[key] = value;
}
which re-joins the value on =.
I have tried it locally and in that case the correct value ends up being passed to the scanner: 'sonar.scanner.javaOpts': '-XX:+PrintFlagsFinal -Xlog:gc*:file=gc.log'
Using sonar.scanner.javaOpts might not be the right thing for my use case (analysing GC logs).
I found out that in my case sonar-engine is used and it does not seem to be possible in sonar-scanner-npm to pass JVM arguments to it. There is scanner-engine.ts which suggests that you can set something within scanOptions.jvmOptions but at least since the already mentioned commit (see above) commander is used for processing CLI arguments to sonar-scanner-npm and that only allows -v, -X and -D and anything from CLI never makes it into scanOptions anyway.