Add logs before removing repo
[osm/devops.git] / jenkins / ci-pipelines / ci_helper.groovy
index f343076..4f1d32d 100644 (file)
@@ -29,24 +29,25 @@ def get_archive(artifactory_server, mdg, branch, build_name, build_number, patte
      "files": [
         {
           "target": "./",
-          "pattern": "${repo_prefix}${mdg}/${branch}/${build_number}/${pattern}",
-          "build": "${build_name}/${build_number}"
+          "pattern": "${repo_prefix}${mdg}/${branch}/${build_number}/${pattern}"
         }
      ]
     }"""
 
+    println("Searching Artifactory with ${downloadSpec}")
+
     def results = server.download(downloadSpec)
     // Save the list of URLs that we need to pass to the dockerfiles for build
     def debian_packages = []
-    for ( result in results.getDependencies()) {
+    for ( result in results.getDependencies() ) {
         if (result.remotePath.contains(".deb")) {
             debian_packages.add(result.remotePath)
         }
     }
 
     // workaround.  flatten repo to remove specific build num from the directory
-    sh "cp -R ${branch}/${build_number}/* ."
-    sh "rm -rf ${branch}/${build_number}"
+    sh "cp -Rv ${branch}/${build_number}/* ."
+    sh "rm -rfv ${branch}/${build_number}"
 
     return debian_packages
 }
@@ -68,7 +69,24 @@ def lxc_file_push(container_name,file,destination) {
 def start_http_server(repo_dir,server_name,port) {
     sh "docker run -dit --name ${server_name} -p ${port}:80 -v ${repo_dir}:/usr/local/apache2/htdocs/ httpd:2.4"
     def http_server_ip = sh(returnStdout:true,  script: "docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${server_name}").trim()
-    return "http://${http_server_ip}/"
+    return "http://${http_server_ip}:${port}/"
+}
+
+def check_status_http_server(ip, port) {
+    alive = false
+    timeout(time: 1, unit: 'MINUTES') {
+        while (!alive) {
+            output = sh(
+                returnStatus: true,
+                script: "wget http://${ip}:${port}/release/dists/unstable/Release")
+            alive = (output == 0)
+            if (!alive) {
+                sleep(time: 5, unit: 'SECONDS')
+            }
+        }
+    }
+    println('HTTP server is ready and accepting http connections')
+    return
 }
 
 def lxc_get_file(container_name,file,destination) {