Add cvp-sanity job code
See also https://gerrit.mcp.mirantis.net/#/c/11078/
Change-Id: I17fb08447702595646398cc58a9289fa54a8b5fa
diff --git a/cvp-sanity.groovy b/cvp-sanity.groovy
new file mode 100644
index 0000000..53c044a
--- /dev/null
+++ b/cvp-sanity.groovy
@@ -0,0 +1,38 @@
+/**
+ *
+ * Launch sanity validation of the cloud
+ *
+ * Expected parameters:
+ * SALT_MASTER_URL URL of Salt master
+ * SALT_MASTER_CREDENTIALS Credentials to the Salt API
+ *
+ * SANITY_TESTS_SET Leave empty for full run or choose a file (test), e.g. test_mtu.py
+ * SANITY_TESTS_REPO CVP-sanity-checks repo to clone
+ * PROXY Proxy to use for cloning repo or for pip
+ *
+ */
+
+validate = new com.mirantis.mcp.Validate()
+
+def artifacts_dir = 'validation_artifacts/'
+
+node() {
+ try{
+ stage('Initialization') {
+ validate.prepareVenv(SANITY_TESTS_REPO, PROXY)
+ }
+
+ stage('Run Infra tests') {
+ sh "mkdir -p ${artifacts_dir}"
+ validate.runSanityTests(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS, SANITY_TESTS_SET, artifacts_dir)
+ }
+ stage ('Publish results') {
+ archiveArtifacts artifacts: "${artifacts_dir}/*"
+ junit "${artifacts_dir}/*.xml"
+ }
+ } catch (Throwable e) {
+ // If there was an error or exception thrown, the build failed
+ currentBuild.result = "FAILURE"
+ throw e
+ }
+}