From: Zipeng WU Date: Thu, 18 Nov 2021 15:56:25 +0000 (+0100) Subject: SONAR-15639 Measure time of SQ analysis step on Cirrus CI X-Git-Tag: 9.3.0.51899~171 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=aa640be9e2b9cfa2c027ef0768940b31ebb5536c;p=sonarqube.git SONAR-15639 Measure time of SQ analysis step on Cirrus CI --- diff --git a/build.gradle b/build.gradle index 3cb1467fffb..042beb69d0a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import groovy.json.JsonOutput + plugins { // Ordered alphabeticly id 'com.github.ben-manes.versions' version '0.33.0' @@ -689,13 +691,26 @@ gradle.projectsEvaluated { gradle -> } ext.osAdaptiveCommand = { commands -> - def newCommands = [] - - if (System.properties['os.name'].toLowerCase().contains('windows')) { - newCommands = ['cmd', '/c'] - } + def newCommands = [] - newCommands.addAll(commands) + if (System.properties['os.name'].toLowerCase().contains('windows')) { + newCommands = ['cmd', '/c'] + } - return newCommands + newCommands.addAll(commands) + + return newCommands } + +tasks.named('sonarqube') { + long taskStart + doFirst { + taskStart = System.currentTimeMillis() + } + doLast { + long taskDuration = System.currentTimeMillis() - taskStart + File outputFile = new File("/tmp/analysis-monitoring.log") + outputFile.append(JsonOutput.toJson([category: "Analysis", suite: "Standalone", operation: "total", duration: taskDuration]) + '\n') + } +} +