Merge "Completed gating pipeline, fixed aborting job pipeline"
diff --git a/aptly-promote-pipeline.groovy b/aptly-promote-pipeline.groovy
index 6c84606..7c1cd42 100644
--- a/aptly-promote-pipeline.groovy
+++ b/aptly-promote-pipeline.groovy
@@ -1,11 +1,27 @@
 def common = new com.mirantis.mk.Common()
 def aptly = new com.mirantis.mk.Aptly()
+
+
+def packages
+try {
+  packages = PACKAGES
+} catch (MissingPropertyException e) {
+  packages = ""
+}
+
+def components
+try {
+  components = COMPONENTS
+} catch (MissingPropertyException e) {
+  components = ""
+}
+
 node() {
   try{
     stage("promote") {
       lock("aptly-api") {
         wrap([$class: 'AnsiColorBuildWrapper']) {
-          aptly.promotePublish(APTLY_URL, SOURCE, TARGET, RECREATE, null, null, DIFF_ONLY)
+          aptly.promotePublish(APTLY_URL, SOURCE, TARGET, RECREATE, components, packages, DIFF_ONLY)
         }
       }
     }
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..22e28f2 100644
--- a/lab-pipeline.groovy
+++ b/lab-pipeline.groovy
@@ -292,6 +292,10 @@
                 stage('Install OpenStack control') {
                     //orchestrate.installOpenstackMkControl(saltMaster)
 
+                    // Install horizon dashboard
+                    salt.enforceState(saltMaster, 'I@horizon:server', 'horizon', true)
+                    salt.enforceState(saltMaster, 'I@nginx:server', 'nginx', true)
+
                     // setup keystone service
                     //runSaltProcessStep(saltMaster, 'I@keystone:server', 'state.sls', ['keystone.server'], 1)
                     salt.enforceState(saltMaster, 'I@keystone:server and *01*', 'keystone.server', true)
@@ -316,8 +320,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 +333,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
@@ -339,10 +343,6 @@
                     salt.enforceState(saltMaster, 'I@heat:server', 'heat', true)
                     salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true)
 
-                    // Install horizon dashboard
-                    salt.enforceState(saltMaster, 'I@horizon:server', 'horizon', true)
-                    salt.enforceState(saltMaster, 'I@nginx:server', 'nginx', true)
-
                 }
 
                 stage('Install OpenStack network') {
@@ -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'