Add method for results upload to testrail

Change-Id: Ic69eec3e75e2e59196b7ec73a5874d0ba436e1ba
Related-Prod: OSCORE-270
diff --git a/src/com/mirantis/mk/Test.groovy b/src/com/mirantis/mk/Test.groovy
index ec5e7da..60686cf 100644
--- a/src/com/mirantis/mk/Test.groovy
+++ b/src/com/mirantis/mk/Test.groovy
@@ -101,6 +101,40 @@
     salt.runSaltProcessStep(master, "${target}", 'pkg.install', ["docker.io"])
 }
 
+/** Upload Tempest test results to Testrail
+ *
+ * @param report              Source report to upload
+ * @param image               Testrail reporter image
+ * @param testGroup           Testrail test group
+ * @param credentialsId       Testrail credentials id
+ * @param plan                Testrail test plan
+ * @param milestone           Testrail test milestone
+ * @param suite               Testrail test suite
+ * @param type                Use local shell or remote salt connection
+ * @param master              Salt connection.
+ * @param target              Target node to install docker pkg
+ */
+
+def uploadResultsTestrail(report, image, testGroup, credentialsId, plan, milestone, suite, master = null, target = 'cfg01*') {
+    def salt = new com.mirantis.mk.Salt()
+    def common = new com.mirantis.mk.Common()
+    creds = common.getPasswordCredentials(credentialsId)
+    command =  "docker run --rm --net=host " +
+                           "-v ${report}:/srv/report.xml " +
+                           "-e TESTRAIL_USER=${creds.username} " +
+                           "-e PASS=${creds.password.toString()} " +
+                           "-e TESTRAIL_PLAN_NAME=${plan} " +
+                           "-e TESTRAIL_MILESTONE=${milestone} " +
+                           "-e TESTRAIL_SUITE=${suite} " +
+                           "-e SHORT_TEST_GROUP=${testGroup} " +
+                           "${image}"
+    if (master == null) {
+      sh("${command}")
+    } else {
+      salt.cmdRun(master, "${target}", "${command}")
+    }
+}
+
 /** Archive Rally results in Artifacts
  *
  * @param master              Salt connection.