Sonar.exclusions parameter is not working

sonar.exclusions parameter is not working for Sonarqube, the sonar.exclusions parameter defined in Jenkins or project setting in SonarQube Server it is not taking effect and scanning all files.

i want to exclude css , js and HTML scanning from the project for that i defined sonar.exclusions=/.css, /.js , **/.html*
also defined the path with root path with Jenkins workspace like
sonar.exclusions=$WORKSPACE/src//*.css, $WORKSPACE/src//*.js

Software Stack

  • SonarQube:7.9.4-community
  • Jenkins: 2.235.1
  • Jenkins-plugin: SonarQube Scanner for Jenkins 2.11
  • SonarQube Scanner:- 3.0.0.702

The Jenkins console output is the following . what mistake I am making here can someone guide me?

-Dsonar.sourceEncoding=UTF-8 -Dsonar.coverage.jacoco.xmlReportPaths=/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/build/reports/jacoco/test/jacocoTestReport.xml -Dsonar.sources=/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/src -Dsonar.surefire.reportsPath=/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/build/test-results/test "-Dsonar.exclusions=**/.css, **/.js , **/.html" -Dsonar.projectVersion=Octane-137020-SonarQube-Integrations -Dsonar.java.binaries=/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/build/classes -Dsonar.projectKey=LEMS_X_Exclude -Dsonar.junit.reportPaths=/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/build/test-results/test -Dsonar.projectBaseDir=/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA*
INFO: Scanner configuration file: /opt/cloudhost/apps/.jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQubeScanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.0.0.702
INFO: Java 1.8.0_252 Oracle Corporation (64-bit)
INFO: Linux 3.10.0-1127.10.1.el7.x86_64 amd64
INFO: User cache: /home/stlpdapi/.sonar/cache
INFO: SonarQube server 7.9.4
INFO: Default locale: “en_US”, source code encoding: “UTF-8”
WARN: SonarScanner will require Java 11 to run starting in SonarQube 8.x
INFO: Load global settings
INFO: Load global settings (done) | time=119ms
INFO: Server id: E2281BAA-AXPWxgc9dGdpV1spT8iU
INFO: User cache: /home/stlpdapi/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=79ms
INFO: Load/download plugins (done) | time=134ms
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=3ms
INFO: Project key: LEMS_X_Exclude
INFO: Base dir: /opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA
INFO: Working dir: /opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/.scannerwork
INFO: Load project settings for component key: ‘LEMS_X_Exclude’
INFO: Load project settings for component key: ‘LEMS_X_Exclude’ (done) | time=22ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=75ms
INFO: Detected Jenkins
INFO: Load active rules
INFO: Load active rules (done) | time=747ms
INFO: Indexing files…
INFO: Project configuration:
INFO: Excluded sources: **/.css, **/.js, **/.html*
INFO: Load project repositories
INFO: Load project repositories (done) | time=44ms
INFO: 1221 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for css: Sonar way
INFO: Quality profile for java: Sonar way
INFO: Quality profile for jsp: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: ------------- Run sensors on module LEMS_X_Exclude
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=25ms
INFO: Sensor JavaSquidSensor [java]
INFO: Configured Java source version (sonar.java.source): none
INFO: JavaClasspath initialization
WARN: Bytecode of dependencies was not provided for analysis of source files, you might end up with less precise results. Bytecode can be provided using sonar.java.libraries property.
INFO: JavaClasspath initialization (done) | time=12ms
INFO: JavaTestClasspath initialization
INFO: JavaTestClasspath initialization (done) | time=2ms
INFO: Java Main Files AST scan
INFO: 405 source files to be analyzed
INFO: 405/405 source files have been analyzed
INFO: Java Main Files AST scan (done) | time=57784ms
INFO: Java Test Files AST scan
INFO: 0 source files to be analyzed
INFO: Java Test Files AST scan (done) | time=2ms
INFO: 0/0 source files have been analyzed
INFO: Sensor JavaSquidSensor [java] (done) | time=58443ms
INFO: Sensor SonarCSS Metrics [cssfamily]
INFO: Sensor SonarCSS Metrics [cssfamily] (done) | time=125ms
INFO: Sensor SonarCSS Rules [cssfamily]
ERROR: CSS rules were not executed. Error when running: ‘node -v’. Is Node.js available during analysis?
org.sonarsource.nodejs.NodeCommandException: Error when running: ‘node -v’. Is Node.js available during analysis?
at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:83)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.getVersion(NodeCommandBuilderImpl.java:196)
at org.sonarsource.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(NodeCommandBuilderImpl.java:169)

  • at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:144)*
  • at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.initNodeCommand(CssAnalyzerBridgeServer.java:133)*
  • at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.startServer(CssAnalyzerBridgeServer.java:101)*
  • at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.startServerLazily(CssAnalyzerBridgeServer.java:153)*
  • at org.sonar.css.plugin.CssRuleSensor.execute(CssRuleSensor.java:99)*
  • at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)*
  • at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)*
  • at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)*
  • at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)*
  • at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)*
  • at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)*
  • at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)*
  • at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)*
  • at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:400)*
  • at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)*
  • at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)*
  • at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)*
  • at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)*
  • at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)*
  • at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)*
  • at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)*
  • at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)*
  • at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:99)*
  • at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)*
  • at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)*
  • at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)*
  • at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)*
  • at java.lang.reflect.Method.invoke(Method.java:498)*
  • at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)*
  • at com.sun.proxy.$Proxy0.execute(Unknown Source)*
  • at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)*
  • at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)*
  • at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)*
  • at org.sonarsource.scanner.cli.Main.execute(Main.java:77)*
  • at org.sonarsource.scanner.cli.Main.main(Main.java:61)*
    Caused by: java.io.IOException: Cannot run program “node”: error=2, No such file or directory
  • at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)*
  • at org.sonarsource.nodejs.NodeCommand$ProcessWrapperImpl.start(NodeCommand.java:175)*
  • at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:79)*
  • … 37 common frames omitted*
    Caused by: java.io.IOException: error=2, No such file or directory
  • at java.lang.UNIXProcess.forkAndExec(Native Method)*
  • at java.lang.UNIXProcess.(UNIXProcess.java:247)*
  • at java.lang.ProcessImpl.start(ProcessImpl.java:134)*
  • at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)*
  • … 39 common frames omitted*

INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=938ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=253ms
INFO: Sensor SurefireSensor [java]
INFO: parsing [/opt/cloudhost/apps/.jenkins/workspace/TEMP_SONARQUBE_CI_CD_LEMS_BUILD_EXTRA/build/test-results/test]
INFO: Sensor SurefireSensor [java] (done) | time=35ms
INFO: Sensor JaCoCoSensor [java]
INFO: Sensor JaCoCoSensor [java] (done) | time=1ms
INFO: Sensor JavaXmlSensor [java]
INFO: 41 source files to be analyzed
INFO: Sensor JavaXmlSensor [java] (done) | time=526ms
INFO: Sensor HTML [web]
INFO: 41/41 source files have been analyzed
INFO: Sensor HTML [web] (done) | time=1841ms
INFO: Sensor XML Sensor [xml]
INFO: 52 source files to be analyzed
INFO: Sensor XML Sensor [xml] (done) | time=562ms
INFO: 52/52 source files have been analyzed
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=22ms
INFO: Sensor Java CPD Block Indexer
INFO: Sensor Java CPD Block Indexer (done) | time=640ms
INFO: 78 files had no CPD blocks
INFO: Calculating CPD for 427 files
INFO: CPD calculation finished
INFO: Analysis report generated in 378ms, dir size=9 MB
INFO: Analysis report compressed in 1574ms, zip size=3 MB
INFO: Analysis report uploaded in 263ms

Hello,

Welcome to the SonarSource Community!

Please confirm that…

is

sonar.exclusions=**/*.css,**/*.js,**/*.html

(could be message board format messing this up)

Adding the debug parameter (-X) will give you more information, including exactly what files on what paths are being picked up.

If those do not point you to the issue, please zip and post the full debug log so I can investigate further.

Cheers

Brian

Thanks for looking into the issue .

The setting for exclusions is defined as sonar.exclusions=**/.css, **/.js , **/.html* .
As suggested find the log in debug mode Sonarqubelog.zip (46.7 KB)
On the meantime, I defined the exclusions setting in SonarQqube project level also still it not reflecting
find the snap for project setting also

I am trying to achieve to skip CSS, Html, js file from scanning.

Thanks & Regards
Giby Alex

Hello,

I reviewed the log and don’t see that any .css, .js or .html files are being analyzed.

Brian

if it is not analysed why in the sonarqube server is showing the line of code in css file
Am I missing something?

Code_issue

Am I missing something if it is not analysed why in the sonarqube server is showing the line of code in css file.