test-salt-formulas: Fix passing SALT_VERSION

Change-Id: Id76c1e2f4730bf51ec3de75b7dd5ad9ce995d078
diff --git a/test-salt-formulas-pipeline.groovy b/test-salt-formulas-pipeline.groovy
index fe7809c..37983c0 100644
--- a/test-salt-formulas-pipeline.groovy
+++ b/test-salt-formulas-pipeline.groovy
@@ -97,8 +97,14 @@
     }
     stage("test") {
       if (checkouted) {
-        sh("make clean")
-        sh("[ $SALT_VERSION != 'latest' ] || export SALT_VERSION=''; make test")
+        try {
+          saltVersion = SALT_VERSION
+        } catch (MissingPropertyException e) {
+          saltVersion = "latest"
+        }
+        withEnv(["SALT_VERSION=${saltVersion}"]) {
+          sh("make clean && make test")
+        }
       }
     }
     stage("kitchen") {
@@ -150,4 +156,4 @@
     }
     common.sendNotification(currentBuild.result, "", ["slack"])
   }
-}
\ No newline at end of file
+}