Issue
-
Multibranch pipeline takes time to load all branches in the UI and sometimes it times out.
-
In the Slow request logs we can see below stack traces related to Sonarqube Scanner Plugin.
"11691msec elapsed in Handling GET /jenkins/view/.../ from ... : Jetty (winstone)-98612 View/index.jelly ItemColumn/column.jelly java.base@11.0.16.1/java.net.SocketInputStream.socketRead0(Native Method) ... org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:111) hudson.plugins.sonar.client.HttpClient.getHttp(HttpClient.java:37) hudson.plugins.sonar.client.WsClient.getCETask(WsClient.java:51) hudson.plugins.sonar.client.SQProjectResolver.requestCETaskDetails(SQProjectResolver.java:98) hudson.plugins.sonar.client.SQProjectResolver.resolve(SQProjectResolver.java:75) hudson.plugins.sonar.action.SonarCacheAction.get(SonarCacheAction.java:76) hudson.plugins.sonar.action.SonarCacheAction.get(SonarCacheAction.java:52) hudson.plugins.sonar.action.SonarProjectActionFactory.createProjectPage(SonarProjectActionFactory.java:117) hudson.plugins.sonar.action.SonarProjectActionFactory.createFor(SonarProjectActionFactory.java:83) hudson.plugins.sonar.action.SonarProjectActionFactory.createFor(SonarProjectActionFactory.java:42) hudson.model.Actionable.createFor(Actionable.java:115) hudson.model.Actionable.getAction(Actionable.java:332) jenkins.branch.ItemColumn.isPrimary(ItemColumn.java:67)
Resolution
Upgrade SonarQube Scanner plugin to version 2.16 or higher.
The problem is that if the job uses the Sonarqube Plugin in the pipeline.SonarQube adds metadata (Action) to Pipelines on the fly (SonarProjectActionFactory). It is a common pattern in Jenkins, but the SonarQube Scanner plugin does some heavy blocking actions when it does it. It might query the SonarQube server multiple times. It caches the data, but if caches are cold or expired, the process will be slow. Pipeline Metadata can be used to varying extent when pages are rendered. For example, Bitbucket’s branch name and a primary branch flag are stored as similar metadata, both are necessary to render the Multibranch Pipeline’s default view. To get to the metadata page needs, Jenkins first loads all metadata, hence SonarQube Scanner plugin can slow down rendering of long lists of pipelines significantly if its caches are cold.
References
-
Also see related issue JENKINS-70694