Azure DevOps pipeline SonarCSS ERROR: Analysis didn't terminate normally, please verify ERROR and WARN logs above. Exit code 1

Hi community,
SonarCloud is throwing this error on one of our Azure DevOps pipeline
ERROR: Analysis didn't terminate normally, please verify ERROR and WARN logs above. Exit code 1.
The problem is that there are no error or warn logs to look into, which makes debugging quite difficult.

Apparently it fails on analysing the .css and .scss files, but it doesn’t prevent SonarCloud from keeping running and analysing the rest of files (.html, .ts, etc.), which is fine because at least we get a partial analysis and the pipeline doesn’t break.

Here are some log parts related to versions, .scss files and SonarCSS plugin. I’ve shortened it for convenience but I could also post the full log if necessary:

==============================================================================
Task         : Run Code Analysis
Description  : Run scanner and upload the results to the SonarCloud server.
Version      : 1.9.0
Author       : sonarsource
Help         : This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
==============================================================================
...
07:04:27.366 INFO: SonarQube Scanner 4.1.0.1829
07:04:27.366 INFO: Java 1.8.0_152 Oracle Corporation (32-bit)
07:04:27.366 INFO: Windows Server 2016 10.0 x86
...
07:04:27.803 INFO: SonarQube server 8.0.0
07:04:27.803 INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
07:04:27.803 DEBUG: Work directory: F:\agent5\_work\402\s\.scannerwork
07:04:27.803 DEBUG: Execution execute
07:04:27.975 DEBUG: SonarCloud 8.0.0.678
...
07:04:28.600 DEBUG: Plugins:
07:04:28.600 DEBUG:   * SonarCSS 1.1.1.1010 (cssfamily)
07:04:28.600 DEBUG:   * SonarPLSQL 3.4.1.2576 (plsql)
07:04:28.600 DEBUG:   * SonarScala 1.7.0.883 (sonarscala)
07:04:28.600 DEBUG:   * SonarC# 7.16.0.8981 (csharp)
07:04:28.600 DEBUG:   * Vulnerability Analysis 8.0.0-M1.5391 (security)
07:04:28.600 DEBUG:   * SonarJava 5.14.0.18788 (java)
07:04:28.600 DEBUG:   * SonarHTML 3.2.0.2082 (web)
07:04:28.600 DEBUG:   * SonarFlex 2.5.1.1831 (flex)
07:04:28.600 DEBUG:   * SonarXML 2.0.1.2020 (xml)
07:04:28.600 DEBUG:   * SonarTS 1.9.0.3766 (typescript)
07:04:28.600 DEBUG:   * SonarVB 7.16.0.8981 (vbnet)
07:04:28.600 DEBUG:   * SonarSwift 4.1.0.3087 (swift)
07:04:28.600 DEBUG:   * SonarCFamily 6.3.0.11371 (cpp)
07:04:28.600 DEBUG:   * SonarPython 1.15.0.4069 (python)
07:04:28.600 DEBUG:   * JaCoCo 1.0.2.475 (jacoco)
07:04:28.600 DEBUG:   * Mercurial 1.1.2 (scmmercurial)
07:04:28.600 DEBUG:   * SonarGo 1.7.0.883 (go)
07:04:28.600 DEBUG:   * SonarKotlin 1.7.0.883 (kotlin)
07:04:28.600 DEBUG:   * SonarTSQL 1.4.0.3334 (tsql)
07:04:28.600 DEBUG:   * SonarApex 1.7.0.883 (sonarapex)
07:04:28.600 DEBUG:   * SonarJS 5.2.1.7778 (javascript)
07:04:28.600 DEBUG:   * SonarRuby 1.7.0.883 (ruby)
07:04:28.600 DEBUG:   * Vulnerability Rules for C# 8.0.0-M1.5391 (securitycsharpfrontend)
07:04:28.600 DEBUG:   * Vulnerability Rules for Java 8.0.0-M1.5391 (securityjavafrontend)
07:04:28.600 DEBUG:   * License for SonarLint 8.0.0.678 (license)
07:04:28.600 DEBUG:   * SonarCOBOL 4.4.0.3403 (cobol)
07:04:28.600 DEBUG:   * Git 1.10.0.1786 (scmgit)
07:04:28.600 DEBUG:   * SonarPHP 3.2.0.4868 (php)
07:04:28.600 DEBUG:   * SonarABAP 3.8.0.2034 (abap)
07:04:28.600 DEBUG:   * Vulnerability Rules for PHP 8.0.0-M1.5391 (securityphpfrontend)
...
07:04:38.180 DEBUG: 'src\app\app-routing.module.ts' indexed with language 'ts'
07:04:38.180 DEBUG: 'src\app\app.component.html' indexed with language 'web'
07:04:38.180 DEBUG: 'src/app/app.component.scss' generated metadata with charset 'windows-1252'
07:04:38.180 DEBUG: 'src\app\app.component.scss' indexed with language 'css'
07:04:38.196 DEBUG: 'src\app\app.component.ts' indexed with language 'ts'
07:04:38.196 DEBUG: 'src\app\app.module.ts' indexed with language 'ts'
...
07:04:39.102 INFO: Quality profile for css: Sonar way
...
07:04:41.227 DEBUG: Sensors : SonarCSS Metrics -> SonarCSS Rules -> JavaXmlSensor -> HTML -> XML Sensor -> SonarTS -> JaCoCo XML Report Importer -> SonarJS -> ESLint-based SonarJS -> JavaSecuritySensor -> CSharpSecuritySensor -> PhpSecuritySensor
07:04:41.227 INFO: Sensor SonarCSS Metrics [cssfamily]
07:04:42.634 INFO: Sensor SonarCSS Metrics [cssfamily] (done) | time=1407ms
07:04:42.634 INFO: Sensor SonarCSS Rules [cssfamily]
07:04:42.634 DEBUG: Deploying bundle to F:\agent5\_work\402\s\.scannerwork
07:04:56.499 DEBUG: Using default Node.js executable: 'node'.
07:04:56.499 DEBUG: Checking Node.js version
07:04:56.516 DEBUG: Launching command [node, -v]
07:04:56.547 DEBUG: Using Node.js v10.16.0.
07:04:56.547 DEBUG: Starting process: node F:\agent5\_work\402\s\.scannerwork\css-bundle\node_modules\stylelint\bin\stylelint F:\agent5\_work\402\s\**\*{.css,.less,.scss,.html,.xhtml,.cshtml,.vbhtml,.aspx,.ascx,.rhtml,.erb,.shtm,.shtml,php,php3,php4,php5,phtml,inc} --config F:\agent5\_work\402\s\.scannerwork\css-bundle\stylelintconfig.json -f json
07:04:56.547 DEBUG: Launching command [node, F:\agent5\_work\402\s\.scannerwork\css-bundle\node_modules\stylelint\bin\stylelint, F:\agent5\_work\402\s\**\*{.css,.less,.scss,.html,.xhtml,.cshtml,.vbhtml,.aspx,.ascx,.rhtml,.erb,.shtm,.shtml,php,php3,php4,php5,phtml,inc}, --config, F:\agent5\_work\402\s\.scannerwork\css-bundle\stylelintconfig.json, -f, json]
##[error]07:04:59.840 ERROR: Analysis didn't terminate normally, please verify ERROR and WARN logs above. Exit code 1
##[debug]Processed: ##vso[task.logissue type=error;]07:04:59.840 ERROR: Analysis didn't terminate normally, please verify ERROR and WARN logs above. Exit code 1
07:04:59.840 ERROR: Analysis didn't terminate normally, please verify ERROR and WARN logs above. Exit code 1
07:04:59.840 INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=17206ms
...

Can someone throw some light on why is this happening and how can I solve it?
Thanks in advance.

Hi,

Is there a possibility for you to try run this command “node F:\agent5_work\402\s.scannerwork\css-bundle\node_modules\stylelint\bin\stylelint F:\agent5_work\402\s***{.css,.less,.scss,.html,.xhtml,.cshtml,.vbhtml,.aspx,.ascx,.rhtml,.erb,.shtm,.shtml,php,php3,php4,php5,phtml,inc} --config F:\agent5_work\402\s.scannerwork\css-bundle\stylelintconfig.json -f json”

directly from a commandline tool, and see if you get more logs ?

Thank you.

Hi,

Running the command directly from the CLI on our pipeline is quite tricky but actually I had enabled all debugging options on it, what gives all kind or warnings and errors back from the CLI, and there was nothing else besides the aforementioned error.

Additionally, if I run locally Stylelint 9.2.1 over Node 10.16.0 with the same stylelintconfig.json and same source files I get no errors but the report correctly.

Thanks again.

I mean locally and directly, not through SonarCloud, same versions. Which asserts my thought that the SonarCSS plugin might have something to do with it.

Any clue on why might this be happening?

Hi Pablo,

Could you please share your sonar-project.properties configuration file?

I just checked CSS analyzis on Azure Devops + SonarCloud and could not reproduce the issue so it might be related to the configuration.

Thanks
Nicolas

Hi Nicolas, thanks for checking.

We don’t use a sonar-project.properties file but the manual mode. Here’s the task configuration on our pipeline YAML file (I’ve removed the sensitive data):

- task: SonarCloudPrepare@1
  displayName: 'SonarCloud: Prepare analysis'
  inputs:
    SonarCloud: '' //removed
    organization: '' //removed
    scannerMode: 'CLI'
    configMode: 'manual'
    cliProjectKey: '' //removed
    cliProjectName: '' //removed
    cliSources: 'src'
    extraProperties: |
      sonar.exclusions=**/*.spec.ts
      sonar.branch.name=$(Build.SourceBranchName)
      sonar.projectVersion=$(Build.BuildId)

Let me know if there’s any additional info I can provide.

Heads up on this, I’ve run Stylelint from .scannerwork directly on the pipeline and it exits with code 2, which means that the linter has ran properly and found linting errors

Here the command I’ve used: node ./.scannerwork/css-bundle/node_modules/stylelint/bin/stylelint \"./src/**/*{.css,.less,.scss,.html,.xhtml,.cshtml,.vbhtml,.aspx,.ascx,.rhtml,.erb,.shtm,.shtml,php,php3,php4,php5,phtml,inc}\" --config ./.scannerwork/css-bundle/stylelintconfig.json -f json

Does this info help? This is becoming really frustrating and I’m thinking of running Stylelint directly on the pipeline, generate the report and let SonarCloud read that report, but how could I disable the CSS linting on SonarCloud side so I don’t get that annoying error anymore?

Any help will be much appreciated.

Hi @p.lopetegi,

Sorry for the long delay.
Indeed it’s hard to investigate the problem as there is no logs. Currently we forward stderr of stylelint to our logs but it can print error in stdout (which is ignored in case of bad exit code). This ticket is supposed to fix this and we will see why stylelint failed.

So I suggest you to wait until we implement this fix of logging and deploy it on the SonarCloud.

In the meantime to avoid this sensor being executed you can create empty profile for CSS, when no rules are activated, stylelint is not triggered.

Hi Lena, thanks for your answer.

I found a temporary workaround for this: I created an empty profile for CSS and run Stylelint on the pipeline, then the report is uploaded to SonarCloud. It’s been running flawless for seven weeks now.
I’m looking forward to that fix, we definitely want to use the CSS plugin instead of Stylelint to keep all configurations on SonarCloud.

1 Like

Hi,

FYI we deployed new version of CSS analyzer on SonarCloud

Nice, I’ll try to remove the workaround next week.

Thanks for the heads up!