From 9daf85eb18d925aba0cff5fe23f6d0e9e9eae47c Mon Sep 17 00:00:00 2001
From: Martin Hierholzer <martin.hierholzer@desy.de>
Date: Mon, 19 Nov 2018 11:36:44 +0100
Subject: [PATCH] create builds.txt artefact also for doocs libraries

---
 vars/buildDoocsLibrary.groovy | 14 ++++++++++++--
 vars/buildTestDeploy.groovy   | 27 +++++++++++++++------------
 2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/vars/buildDoocsLibrary.groovy b/vars/buildDoocsLibrary.groovy
index 4f5c71e..b0d425e 100644
--- a/vars/buildDoocsLibrary.groovy
+++ b/vars/buildDoocsLibrary.groovy
@@ -14,19 +14,29 @@ def call(String libraryName, ArrayList<String> dependencyList) {
                  'bionic-Debug',
                  'bionic-Release' ]
 
+  // publish our list of builds as artefact for our downstream builds
+  script {
+    node('Docker') {
+      writeFile file: "builds.txt", text: builds.join("\n")
+      archiveArtifacts artifacts: "builds.txt", onlyIfSuccessful: false
+    }
+  }
+
+  // form comma-separated list of dependencies as needed for the trigger configuration
   def dependencies = dependencyList.join(',')
   if(dependencies == "") {
     dependencies = "Create Docker Images"
   }
 
+  pipeline {
+    agent none
+
     // setup build trigger
     triggers {
       pollSCM 'H/5 * * * *'
       upstream dependencies
     }
 
-  pipeline {
-    agent none
     stages {
       stage('build') {
         // Run the build stages for all labels + build types in parallel, each in a separate docker container
diff --git a/vars/buildTestDeploy.groovy b/vars/buildTestDeploy.groovy
index eb7b0c7..dd5849a 100644
--- a/vars/buildTestDeploy.groovy
+++ b/vars/buildTestDeploy.groovy
@@ -17,22 +17,25 @@ def call(ArrayList<String> dependencyList, String gitUrl='') {
 
   // only keep builds which exist for all dependencies
   script {
-    dependencyList.each {
-      if( it != "" ) {
-        copyArtifacts filter: "builds.txt", fingerprintArtifacts: true, projectName: "${it}", selector: lastSuccessful(), target: "artefacts"
-        myFile = readFile(env.WORKSPACE+"/artefacts/builds.txt")
-        def depBuilds = myFile.split("\n")
-        builds.each {
-          if(depBuilds.find { it == owner.it } != it) {
-            builds.removeAll { it == owner.it }
+    node('Docker') {
+      dependencyList.each {
+        if( it != "" ) {
+          copyArtifacts filter: "builds.txt", fingerprintArtifacts: true, projectName: "${it}", selector: lastSuccessful(), target: "artefacts"
+          myFile = readFile(env.WORKSPACE+"/artefacts/builds.txt")
+          def depBuilds = myFile.split("\n")
+          builds.each {
+            def build = it
+            if(depBuilds.find { it == build } != it) {
+              builds.removeAll { it == build }
+            }
           }
         }
       }
-    }
 
-    // publish our list of builds as artefact for our downstream builds
-    writeFile("builds.txt", builds.join("\n"))
-    archiveArtifacts artifacts: "builds.txt", onlyIfSuccessful: false
+      // publish our list of builds as artefact for our downstream builds
+      writeFile file: "builds.txt", text: builds.join("\n")
+      archiveArtifacts artifacts: "builds.txt", onlyIfSuccessful: false
+    }
   }
 
   // form comma-separated list of dependencies as needed for the trigger configuration
-- 
GitLab