test-system-reclass-pipeline.groovy auto-ident

  * 0-change

Change-Id: I0bac0e67c999e53aaca1600052a5b895aaea03e4
diff --git a/test-system-reclass-pipeline.groovy b/test-system-reclass-pipeline.groovy
index fa16739..a49d989 100644
--- a/test-system-reclass-pipeline.groovy
+++ b/test-system-reclass-pipeline.groovy
@@ -10,9 +10,9 @@
 
 def gerritRef
 try {
-  gerritRef = GERRIT_REFSPEC
+    gerritRef = GERRIT_REFSPEC
 } catch (MissingPropertyException e) {
-  gerritRef = null
+    gerritRef = null
 }
 
 def defaultGitRef, defaultGitUrl
@@ -28,76 +28,76 @@
 def systemRefspec = "HEAD"
 def formulasRevision = 'testing'
 timeout(time: 12, unit: 'HOURS') {
-  node() {
-    try {
-      stage("Checkout") {
-        if (gerritRef) {
-          // job is triggered by Gerrit
-          // test if change aren't already merged
-          def gerritChange = gerrit.getGerritChange(GERRIT_NAME, GERRIT_HOST, GERRIT_CHANGE_NUMBER, gerritCredentials)
-          merged = gerritChange.status == "MERGED"
-          if(!merged){
-            checkouted = gerrit.gerritPatchsetCheckout ([
-              credentialsId : gerritCredentials
-            ])
-            systemRefspec = GERRIT_REFSPEC
-          }
-          // change defaultGit variables if job triggered from Gerrit
-          defaultGitUrl = "${GERRIT_SCHEME}://${GERRIT_NAME}@${GERRIT_HOST}:${GERRIT_PORT}/${GERRIT_PROJECT}"
-        } else if(defaultGitRef && defaultGitUrl) {
-            checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "HEAD", gerritCredentials)
+    node() {
+        try {
+            stage("Checkout") {
+                if (gerritRef) {
+                    // job is triggered by Gerrit
+                    // test if change aren't already merged
+                    def gerritChange = gerrit.getGerritChange(GERRIT_NAME, GERRIT_HOST, GERRIT_CHANGE_NUMBER, gerritCredentials)
+                    merged = gerritChange.status == "MERGED"
+                    if (!merged) {
+                        checkouted = gerrit.gerritPatchsetCheckout([
+                            credentialsId: gerritCredentials
+                        ])
+                        systemRefspec = GERRIT_REFSPEC
+                    }
+                    // change defaultGit variables if job triggered from Gerrit
+                    defaultGitUrl = "${GERRIT_SCHEME}://${GERRIT_NAME}@${GERRIT_HOST}:${GERRIT_PORT}/${GERRIT_PROJECT}"
+                } else if (defaultGitRef && defaultGitUrl) {
+                    checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "HEAD", gerritCredentials)
+                }
+            }
+
+            stage("Test") {
+                if (merged) {
+                    common.successMsg("Gerrit change is already merged, no need to test them")
+                } else {
+                    if (checkouted) {
+
+                        def documentationOnly = false
+                        if (gerritRef) {
+                            documentationOnly = sh(script: "git diff-tree --no-commit-id --name-only -r HEAD | grep -v .releasenotes", returnStatus: true) == 1
+                        }
+
+                        sh("git diff-tree --no-commit-id --diff-filter=d --name-only -r HEAD  | grep .yml | xargs -I {}  python -c \"import yaml; yaml.load(open('{}', 'r'))\" \\;")
+
+                        def branches = [:]
+                        def testModels = documentationOnly ? [] : TEST_MODELS.split(',')
+                        for (int i = 0; i < testModels.size(); i++) {
+                            def cluster = testModels[i]
+                            def clusterGitUrl = defaultGitUrl.substring(0, defaultGitUrl.lastIndexOf("/") + 1) + cluster
+                            branches["${cluster}"] = {
+                                build job: "test-salt-model-${cluster}", parameters: [
+                                    [$class: 'StringParameterValue', name: 'DEFAULT_GIT_URL', value: clusterGitUrl],
+                                    [$class: 'StringParameterValue', name: 'DEFAULT_GIT_REF', value: "HEAD"],
+                                    [$class: 'StringParameterValue', name: 'SYSTEM_GIT_URL', value: defaultGitUrl],
+                                    [$class: 'StringParameterValue', name: 'SYSTEM_GIT_REF', value: systemRefspec],
+                                    [$class: 'StringParameterValue', name: 'FORMULAS_REVISION', value: formulasRevision],
+                                ]
+                            }
+                        }
+                        branches["cookiecutter"] = {
+                            build job: "test-mk-cookiecutter-templates", parameters: [
+                                [$class: 'StringParameterValue', name: 'SYSTEM_GIT_URL', value: defaultGitUrl],
+                                [$class: 'StringParameterValue', name: 'SYSTEM_GIT_REF', value: systemRefspec],
+                                [$class: 'StringParameterValue', name: 'DISTRIB_REVISION', value: formulasRevision]
+
+                            ]
+                        }
+                        parallel branches
+                    } else {
+                        throw new Exception("Cannot checkout gerrit patchset, GERRIT_REFSPEC and DEFAULT_GIT_REF is null")
+                    }
+                }
+            }
+        } catch (Throwable e) {
+            // If there was an error or exception thrown, the build failed
+            currentBuild.result = "FAILURE"
+            currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
+            throw e
+        } finally {
+            common.sendNotification(currentBuild.result, "", ["slack"])
         }
-      }
-
-      stage("Test") {
-        if(merged){
-          common.successMsg("Gerrit change is already merged, no need to test them")
-        }else{
-          if(checkouted){
-
-            def documentationOnly = false
-            if (gerritRef) {
-              documentationOnly = sh(script: "git diff-tree --no-commit-id --name-only -r HEAD | grep -v .releasenotes", returnStatus: true) == 1
-            }
-
-            sh("git diff-tree --no-commit-id --diff-filter=d --name-only -r HEAD  | grep .yml | xargs -I {}  python -c \"import yaml; yaml.load(open('{}', 'r'))\" \\;")
-
-            def branches = [:]
-            def testModels = documentationOnly ? [] : TEST_MODELS.split(',')
-            for (int i = 0; i < testModels.size(); i++) {
-              def cluster = testModels[i]
-              def clusterGitUrl = defaultGitUrl.substring(0, defaultGitUrl.lastIndexOf("/") + 1) + cluster
-              branches["${cluster}"] = {
-                build job: "test-salt-model-${cluster}", parameters: [
-                  [$class: 'StringParameterValue', name: 'DEFAULT_GIT_URL', value: clusterGitUrl],
-                  [$class: 'StringParameterValue', name: 'DEFAULT_GIT_REF', value: "HEAD"],
-                  [$class: 'StringParameterValue', name: 'SYSTEM_GIT_URL', value: defaultGitUrl],
-                  [$class: 'StringParameterValue', name: 'SYSTEM_GIT_REF', value: systemRefspec],
-                  [$class: 'StringParameterValue', name: 'FORMULAS_REVISION', value: formulasRevision],
-                ]
-              }
-            }
-            branches["cookiecutter"] = {
-              build job: "test-mk-cookiecutter-templates", parameters: [
-                [$class: 'StringParameterValue', name: 'SYSTEM_GIT_URL', value: defaultGitUrl],
-                [$class: 'StringParameterValue', name: 'SYSTEM_GIT_REF', value: systemRefspec],
-                [$class: 'StringParameterValue', name: 'DISTRIB_REVISION', value: formulasRevision]
-
-              ]
-            }
-            parallel branches
-          }else{
-             throw new Exception("Cannot checkout gerrit patchset, GERRIT_REFSPEC and DEFAULT_GIT_REF is null")
-          }
-        }
-      }
-    } catch (Throwable e) {
-        // If there was an error or exception thrown, the build failed
-        currentBuild.result = "FAILURE"
-        currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
-        throw e
-    } finally {
-        common.sendNotification(currentBuild.result,"",["slack"])
     }
-  }
 }