When sonar-scanner CLI runs, it prints tons of INFO network prints to STDOUT which is probably ok when you run it as a standalone cli command. But, when sonar-scanner runs as part of a Jenkins’ pipeline, it makes Jenkins’ output hard to read because of these logs. I don’t want these network prints to be printed to STDOUT.
I can filter them out with grep but I wonder if it can be achieved some parameter similar to sonar.log.level to filter out these network INFO prints
That’s… not standard behavior of the scanner, in regular mode or even with DEBUG logs turned on. Sure, the scanner logs INFO level messages about, broadly, what’s going on during the scan (and when it’s making web calls), but nothing as verbose as what you’ve mentioned.
Here’s the output when I run a scan.
**❯** sonar-scanner -Dsonar.projectKey=test
/Users/colin/Tools/sonar-scanner-4.0.0.1744/bin/sonar-scanner: line 1: #!/bin/sh: No such file or directory
INFO: Scanner configuration file: /Users/colin/Tools/sonar-scanner-4.0.0.1744/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 4.0.0.1744
INFO: Java 11.0.3 Oracle Corporation (64-bit)
INFO: Mac OS X 10.15.4 x86_64
INFO: User cache: /Users/colin/.sonar/cache
INFO: SonarQube server 8.2.0
INFO: Default locale: "en_CH", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=46ms
INFO: Server id: BF41A1F2-AXDzmkBdL_xg6GAzLnww
INFO: User cache: /Users/colin/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=40ms
INFO: Load/download plugins (done) | time=207ms
INFO: Loaded core extensions: developer-scanner
INFO: Process project properties
INFO: Process project properties (done) | time=1ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=3ms
INFO: Project key: test
INFO: Base dir: /Users/colin/source/newoornotnew
INFO: Working dir: /Users/colin/source/newoornotnew/.scannerwork
INFO: Load project settings for component key: 'test'
INFO: Load project settings for component key: 'test' (done) | time=13ms
INFO: Load project branches
INFO: Load project branches (done) | time=15ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=8ms
INFO: Load branch configuration
INFO: Load branch configuration (done) | time=1ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=74ms
Maybe there’s some wonky Jenkins configuration, or some options being passed to the JVM running the scanner (the scanner is all Java, so if you have any JAVA_OPTS or similar environment variables, that could affect things).
It seems so. We are using CodeCloud which basically the same as BitBucket. The prints looks exactly the same as the ones I am seeing. I don’t have access to SonarQube configuration so I can’t tell for sure.
I applied a workaround to it (running on MacOS)
rm -f sonar_output.txt && sonar-scanner $SONAR_PARAMS 2>>sonar_output.txt | tee -a sonar_output.txt
Printing only stdout to console. Both stdout and stderr are wrote to sonar_output.txt