]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15639 Measure time of SQ analysis step on Cirrus CI
authorZipeng WU <zipeng.wu@sonarsource.com>
Thu, 18 Nov 2021 15:56:25 +0000 (16:56 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 19 Nov 2021 20:03:27 +0000 (20:03 +0000)
build.gradle

index 3cb1467fffbb7b8569d4fbfcf4dd78c7539dd57e..042beb69d0a5589e5e4322f88fa655f223351078 100644 (file)
@@ -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')
+  }
+}
+