title: SonarQube doesn't break Jenkins build even though Quality Gate is violated
body: <p>We have Jenkins/SonarQube jobs for Java projects that fail if a developer does not make more than 70% of unit testing code coverage for new code. We're trying to setup the same thing for JavaScript projects.</p>
  
  <p>I have put a lot of work into generating JUnit-like XML files using Karma and a plugin that I wrote for it. Anyway, when I commit new JavaScript code without unit test it doesn't break the Jenkins build. Here is the relevant part of the Jenkins job log:</p>
  
  <pre><code>...
  07:13:37.417 INFO  - Parsing Unit Test run results in Surefire format from folder /home/tomcat/.jenkins/jobs/frontend_common-jscheck/workspace/frontend_common/karma-reports/jstd
  ...
  07:13:38.337 INFO  - Analysing /home/tomcat/.jenkins/jobs/frontend_common-jscheck/workspace/frontend_common/karma-reports/lcov/lcov.txt
  07:13:38.535 WARN  - Could not resolve 2 file paths in lcov.txt, first unresolved path: /home/tomcat/.jenkins/jobs/frontend_common-jscheck/workspace/frontend_common/WebContent/js/jquery/jquery-2.0.3.js
  ...
  07:13:41.962 INFO  - Load previous line hashes of: frontend_common-jscheck:WebContent/js/amp/utils/SlavaUtil.js...
  ...
  07:13:44.427 INFO  - Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
  07:13:44.456 INFO  - Executing post-job class org.sonar.plugins.buildbreaker.AlertBreaker
  07:13:44.459 INFO  - Executing post-job class org.sonar.plugins.buildbreaker.ForbiddenConfigurationBreaker
  INFO: ------------------------------------------------------------------------
  INFO: EXECUTION SUCCESS
  INFO: ------------------------------------------------------------------------
  Total time: 52.594s
  Final Memory: 20M/560M
  INFO: ------------------------------------------------------------------------
  Finished: SUCCESS
  </code></pre>
  
  <p>As you can guess I change code in <code>SlavaUtil.js</code> and you can see that SonarQube analyzes it from the log. I included in the log the warning about not being able to find 2 files from the <code>lcov.txt</code> (one of which it was kind enough to display does exist so I don't know why it doesn't find it) but I think it's not the reason why the build doesn't fail. As you can see in the log it executes those post job classes which I think are supposed to fail the build but they don't.</p>
  
  <p>Question: how to troubleshoot this issue?</p>
  
  <hr>
  
  <p>Update:</p>
  
  <p>I looked at one of the Java project Jenkins log that fails the Quality test, the relevant log looks like this:</p>
  
  <pre><code>10:11:43.780 INFO  - Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
  10:11:43.798 INFO  - Executing post-job class org.sonar.plugins.buildbreaker.AlertBreaker
  10:11:43.801 ERROR - [BUILD BREAKER] Coverage on new code &lt; 70 since previous version (4815 - 2015 Oct 23)
  INFO: ------------------------------------------------------------------------
  INFO: EXECUTION FAILURE
  INFO: ------------------------------------------------------------------------
  Total time: 21.991s
  Final Memory: 18M/240M
  INFO: ------------------------------------------------------------------------
  ERROR: Error during Sonar runner execution
  org.sonar.runner.impl.RunnerException: Unable to execute Sonar
      at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
      at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
      at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
      at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
      at org.sonar.runner.api.Runner.execute(Runner.java:100)
      at org.sonar.runner.Main.executeTask(Main.java:70)
      at org.sonar.runner.Main.execute(Main.java:59)
      at org.sonar.runner.Main.main(Main.java:53)
  Caused by: org.sonar.api.utils.SonarException: Alert thresholds have been hit (1 times).
      at org.sonar.api.batch.BuildBreaker.fail(BuildBreaker.java:34)
      at org.sonar.plugins.buildbreaker.AlertBreaker.analyseMeasures(AlertBreaker.java:57)
      at org.sonar.plugins.buildbreaker.AlertBreaker.executeOn(AlertBreaker.java:50)
      at org.sonar.batch.phases.PostJobsExecutor.execute(PostJobsExecutor.java:72)
      at org.sonar.batch.phases.PostJobsExecutor.execute(PostJobsExecutor.java:61)
      at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:135)
      at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:222)
      at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
      at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
      at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
      at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
      at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:223)
      at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
      at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
      at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:65)
      at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:52)
      at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:128)
      at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
      at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
      at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:171)
      at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
      at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
      at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
      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:483)
      at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
      ... 9 more
  ERROR: 
  ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
  Build step 'Invoke Standalone SonarQube Analysis' marked build as failure
  </code></pre>
  
  <p>As can be seen from the log, it is the <code>AlertBreaker</code> that's supposed to throw the exception. I'm going to try to get the source code and run locally in debug mode, I guess. Don't see any other way to troubleshoot it.</p>