Merge "Improved output of build docker image pipeline"
diff --git a/build-debian-packages-pipeline.groovy b/build-debian-packages-pipeline.groovy
index 83a23fe..8536b5e 100644
--- a/build-debian-packages-pipeline.groovy
+++ b/build-debian-packages-pipeline.groovy
@@ -23,14 +23,14 @@
 
 def uploadPpa
 try {
-  uploadPpa = UPLOAD_PPA
+  uploadPpa = UPLOAD_PPA.toBoolean()
 } catch (MissingPropertyException e) {
   uploadPpa = null
 }
 
 def uploadAptly
 try {
-  uploadAptly = UPLOAD_APTLY
+  uploadAptly = UPLOAD_APTLY.toBoolean()
 } catch (MissingPropertyException e) {
   uploadAptly = true
 }
diff --git a/generate-cookiecutter-products.groovy b/generate-cookiecutter-products.groovy
index d836afb..0986c4e 100644
--- a/generate-cookiecutter-products.groovy
+++ b/generate-cookiecutter-products.groovy
@@ -43,7 +43,9 @@
             }
 
             stage ('Download full Reclass model') {
-                git.checkoutGitRepository(modelEnv, RECLASS_MODEL_URL, RECLASS_MODEL_BRANCH, RECLASS_MODEL_CREDENTIALS)
+                if (RECLASS_MODEL_URL != '') {
+                    git.checkoutGitRepository(modelEnv, RECLASS_MODEL_URL, RECLASS_MODEL_BRANCH, RECLASS_MODEL_CREDENTIALS)
+                }
             }
 
             stage('Generate base infrastructure') {
@@ -124,17 +126,19 @@
             name: cfg01
             domain: ${clusterDomain}
 """
+                sh "mkdir -p ${modelEnv}/nodes/"
                 writeFile(file: nodeFile, text: nodeString)
             }
 
             stage('Inject changes to Reclass model') {
-                git.changeGitBranch(modelEnv, targetBranch)
                 def outputSource = "${env.WORKSPACE}/template/output/"
+                sh "mkdir -p ${outputDestination}"
                 sh(returnStdout: true, script: "cp -vr ${outputSource} ${outputDestination}")
             }
 
             stage ('Save changes to Reclass model') {
                 if (COMMIT_CHANGES.toBoolean()) {
+                    git.changeGitBranch(modelEnv, targetBranch)
                     git.commitGitChanges(modelEnv, "Added new cluster ${clusterName}")
                     git.pushGitChanges(modelEnv, targetBranch, 'origin', RECLASS_MODEL_CREDENTIALS)
                 }
diff --git a/update-package.groovy b/update-package.groovy
index b37fe22..73db088 100644
--- a/update-package.groovy
+++ b/update-package.groovy
@@ -35,13 +35,18 @@
 
         stage('List target servers') {
             minions = salt.getMinions(saltMaster, targetAll)
+
+            if (minions.isEmpty()) {
+                throw new Exception("No minion was targeted")
+            }
+
             if (TARGET_SUBSET_TEST != "") {
                 targetTestSubset = minions.subList(0, Integer.valueOf(TARGET_SUBSET_TEST)).join(' or ')
-            }
-            else {
+            } else {
                 targetTestSubset = minions.join(' or ')
             }
             targetLiveSubset = minions.subList(0, Integer.valueOf(TARGET_SUBSET_LIVE)).join(' or ')
+
             targetLiveAll = minions.join(' or ')
             common.infoMsg("Found nodes: ${targetLiveAll}")
             common.infoMsg("Selected test nodes: ${targetTestSubset}")