Run stage_3 install in new VM
[osm/devops.git] / jenkins / ci-pipelines / ci_helper.groovy
index 21a8373..a2ededc 100644 (file)
@@ -20,19 +20,23 @@ def get_archive(artifactory_server, mdg, branch, build_name, build_number, patte
 
     println("retrieve archive for ${mdg}/${branch}/${build_name}/${build_number}/${pattern}")
 
+    // if the build name does not contain merge, then this is a patchset/staging job
+    if (!build_name.contains('merge')) {
+        branch += '-staging'
+    }
     def repo_prefix = 'osm-'
     def downloadSpec = """{
      "files": [
         {
           "target": "./",
-          "pattern": "${repo_prefix}${mdg}/${branch}/${pattern}",
+          "pattern": "${repo_prefix}${mdg}/${branch}/${build_number}/${pattern}",
           "build": "${build_name}/${build_number}"
         }
      ]
     }"""
 
     server.download(downloadSpec)
-    // workaround.  flatten and repo the specific build num from the directory
+    // workaround.  flatten repo to remove specific build num from the directory
     sh "cp -R ${branch}/${build_num}/* ."
     sh "rm -rf ${branch}/${build_num}"
 }
@@ -51,10 +55,10 @@ def lxc_file_push(container_name,file,destination) {
 
 // start a http server
 // return the http server URL
-def start_http_server(repo_dir,server_name) {
-    sh "docker run -dit --name ${server_name} -v ${repo_dir}:/usr/local/apache2/htdocs/ httpd:2.4"
+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 "-u http://${http_server_ip}/"
+    return "http://${http_server_ip}/"
 }
 
 def lxc_get_file(container_name,file,destination) {
@@ -71,11 +75,13 @@ def systest_run(container_name, test, source_rc = null) {
         pre_source = "/tmp/" + source_rc.substring(source_rc.lastIndexOf('/')+1)
  
         lxc_file_push(container_name,source_rc,pre_source)
-        lxc_run(container_name, "sh -c '. ${pre_source}; make -C devops/systest OSM_HOSTNAME=${so_ip} OSM_RO_HOSTNAME=${ro_ip} ${test}'")
+        result = lxc_run(container_name, "sh -c '. ${pre_source}; make -C devops/systest OSM_HOSTNAME=${so_ip} OSM_RO_HOSTNAME=${ro_ip} ${test}'")
+        echo result
     }
     else
     {
-        lxc_run(container_name, "make -C devops/systest OSM_HOSTNAME=${so_ip} OSM_RO_HOSTNAME=${ro_ip} ${test}")
+        result = lxc_run(container_name, "make -C devops/systest OSM_HOSTNAME=${so_ip} OSM_RO_HOSTNAME=${ro_ip} ${test}")
+        echo result
     }
     lxc_get_file(container_name, "/root/devops/systest/reports/pytest-${test}.xml",'.')
 }
@@ -87,8 +93,14 @@ def get_ip_from_container( container_name ) {
 def archive(artifactory_server,mdg,branch,status) {
     server = Artifactory.server artifactory_server
 
-    def properties = "branch=${branch};status=${status}"
+    def properties = ""
+    //def properties = "branch=${branch};status=${status}"
     def repo_prefix = 'osm-'
+
+    // if the build name does not contain merge, then this is a patchset/staging job
+    if ( !JOB_NAME.contains('merge') ) {
+        branch += '-staging'
+    }
     def uploadSpec = """{
      "files": [
         {
@@ -108,6 +120,12 @@ def archive(artifactory_server,mdg,branch,status) {
           "target": "${repo_prefix}${mdg}/${branch}/${BUILD_NUMBER}/",
           "props": "${properties}",
           "flat": false
+        },
+        {
+          "pattern": "changelog/*",
+          "target": "${repo_prefix}${mdg}/${branch}/${BUILD_NUMBER}/",
+          "props": "${properties}",
+          "flat": false
         }]
     }"""