From 84cd92a4038e46eda624168c0e948c1735aad538 Mon Sep 17 00:00:00 2001
From: Martin Hierholzer <martin.hierholzer@desy.de>
Date: Wed, 21 Nov 2018 13:31:59 +0100
Subject: [PATCH] run analysis job for all -Debug builds of the main job

---
 vars/analysis.groovy | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/vars/analysis.groovy b/vars/analysis.groovy
index fe9a362..a2412d3 100644
--- a/vars/analysis.groovy
+++ b/vars/analysis.groovy
@@ -8,11 +8,24 @@
 
 // This is the function called from the .jenkinsfile
 def call(ArrayList<String> dependencyList) {
+  def builds = []
 
-  // List of builds to be run. Format must be "<docker_image_name>-<cmake_build_type>"
-  def builds = [ 'xenial-Debug',
-                 'bionic-Debug',
-                 'tumbleweed-Debug' ]
+  // Run for all -Debug builds of the main job
+  script {
+    def parentJob = env.JOB_NAME[0..-10]     // remove "-analysis" from the job name, which is 9 chars long
+    node('Docker') {
+      copyArtifacts filter: "builds.txt", fingerprintArtifacts: true, projectName: parentJob, selector: lastSuccessful(), target: "artefacts"
+      myFile = readFile(env.WORKSPACE+"/artefacts/builds.txt")
+      builds = myFile.split("\n").toList()
+      def builds_temp = builds.clone()
+      builds_temp.each {
+        if(!it.endsWith("-Debug")) {
+          def build = it
+          builds.removeAll { it == build }
+        }
+      }
+    }
+  }
 
   pipeline {
     agent none
-- 
GitLab