Merge "Added long running jobs cleanup pipeline"
diff --git a/build-debian-packages-pipeline.groovy b/build-debian-packages-pipeline.groovy
index 58dfe57..83a23fe 100644
--- a/build-debian-packages-pipeline.groovy
+++ b/build-debian-packages-pipeline.groovy
@@ -20,6 +20,21 @@
 } catch (MissingPropertyException e) {
   revisionPostfix = null
 }
+
+def uploadPpa
+try {
+  uploadPpa = UPLOAD_PPA
+} catch (MissingPropertyException e) {
+  uploadPpa = null
+}
+
+def uploadAptly
+try {
+  uploadAptly = UPLOAD_APTLY
+} catch (MissingPropertyException e) {
+  uploadAptly = true
+}
+
 def timestamp = common.getDatetime()
 node("docker") {
   try{
@@ -64,25 +79,35 @@
         currentBuild.result = 'UNSTABLE'
       }
     }
-    lock("aptly-api") {
-      stage("upload") {
-        buildSteps = [:]
-        debFiles = sh script: "ls build-area/*.deb", returnStdout: true
-        for (file in debFiles.tokenize()) {
+
+    if (uploadAptly) {
+      lock("aptly-api") {
+        stage("upload") {
+          buildSteps = [:]
+          debFiles = sh script: "ls build-area/*.deb", returnStdout: true
+          for (file in debFiles.tokenize()) {
             workspace = common.getWorkspace()
             def fh = new File((workspace+"/"+file).trim())
             buildSteps[fh.name.split('_')[0]] = aptly.uploadPackageStep(
-                "build-area/"+fh.name,
-                APTLY_URL,
-                APTLY_REPO,
-                true
-            )
+                  "build-area/"+fh.name,
+                  APTLY_URL,
+                  APTLY_REPO,
+                  true
+              )
+          }
+          parallel buildSteps
         }
-        parallel buildSteps
-      }
-      stage("publish") {
+
+        stage("publish") {
           aptly.snapshotRepo(APTLY_URL, APTLY_REPO, timestamp)
           aptly.publish(APTLY_URL)
+        }
+      }
+    }
+    if (uploadPpa) {
+      stage("upload launchpad") {
+        debian.importGpgKey("launchpad-private")
+        debian.uploadPpa(PPA, "build-area", "launchpad-private")
       }
     }
   } catch (Throwable e) {
diff --git a/lab-pipeline.groovy b/lab-pipeline.groovy
index c391e16..00ba743 100644
--- a/lab-pipeline.groovy
+++ b/lab-pipeline.groovy
@@ -316,8 +316,8 @@
 
                     // Install and check nova service
                     //runSaltProcessStep(saltMaster, 'I@nova:controller', 'state.sls', ['nova'], 1)
-                    salt.enforceState(saltMaster, 'I@nova:controller and *01*', 'nova', true)
-                    salt.enforceState(saltMaster, 'I@nova:controller', 'nova', true)
+                    salt.enforceState(saltMaster, 'I@nova:controller and *01*', 'nova.controller', true)
+                    salt.enforceState(saltMaster, 'I@nova:controller', 'nova.controller', true)
                     salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true)
 
                     // Install and check cinder service
@@ -329,8 +329,8 @@
                     // Install neutron service
                     //runSaltProcessStep(saltMaster, 'I@neutron:server', 'state.sls', ['neutron'], 1)
 
-                    salt.enforceState(saltMaster, 'I@neutron:server and *01*', 'neutron', true)
-                    salt.enforceState(saltMaster, 'I@neutron:server', 'neutron', true)
+                    salt.enforceState(saltMaster, 'I@neutron:server and *01*', 'neutron.server', true)
+                    salt.enforceState(saltMaster, 'I@neutron:server', 'neutron.server', true)
                     salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true)
 
                     // Install heat service
@@ -526,6 +526,13 @@
                 }
             }
 
+            stage('Finalize') {
+                try {
+                    salt.runSaltProcessStep(saltMaster, '*', 'state.apply', [], null, true)
+                } catch (Exception e) {
+                    common.warningMsg('State apply failed but we should continue to run')
+                }
+            }
 
         } catch (Throwable e) {
             currentBuild.result = 'FAILURE'