Merge "Fixed gating 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)
                 }