Completed gating pipeline, fixed aborting job pipeline

Change-Id: Idf2e14c73294760788f8005781971483ead9ef45
diff --git a/abort-long-running-jobs.groovy b/abort-long-running-jobs.groovy
index 0fb8d9a..278c4c3 100644
--- a/abort-long-running-jobs.groovy
+++ b/abort-long-running-jobs.groovy
@@ -15,9 +15,9 @@
     def build = runningBuilds[j]
     int durationInSeconds = (System.currentTimeMillis() - build.getTimeInMillis())/1000.0
     if(durationInSeconds > MAX_ALLOWED_DURATION_IN_SECONDS){
-      common.infoMsg("Aborting ${job.name}-${build.id} takes ${durationInSeconds}s")
+      common.infoMsg("Aborting ${job.name}-${build.id} which is running for ${durationInSeconds}s")
       try{
-        build.finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));
+        build.finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build by long running jobs killer"));
       }catch(e){
         common.errorMsg("Error occured during aborting build: Exception: ${e}")
       }
diff --git a/gating-pipeline.groovy b/gating-pipeline.groovy
index dad56ee..73ef7d6 100644
--- a/gating-pipeline.groovy
+++ b/gating-pipeline.groovy
@@ -11,21 +11,32 @@
 node("python") {
   try{
     stage("test") {
-      wrap([$class: 'AnsiColorBuildWrapper']) {
-        def testJob = String.format("test-%s-%s-latest", JOBS_NAMESPACE, GERRIT_PROJECT)
-        if (_jobExists(testJob)) {
-          common.infoMsg(String.format("Test job %s found, running", testJob))
-          build job: testJob, parameters: [
-            [$class: 'StringParameterValue', name: 'GERRIT_BRANCH', value: GERRIT_BRANCH],
-            [$class: 'StringParameterValue', name: 'GERRIT_NAME', value: GERRIT_NAME],
-            [$class: 'StringParameterValue', name: 'GERRIT_HOST', value: GERRIT_HOST],
-            [$class: 'StringParameterValue', name: 'GERRIT_PORT', value: GERRIT_PORT],
-            [$class: 'StringParameterValue', name: 'GERRIT_PROJECT', value: GERRIT_PROJECT],
-            [$class: 'StringParameterValue', name: 'GERRIT_REFSPEC', value: GERRIT_REFSPEC]
-          ]
-        } else {
-          common.infoMsg(String.format("Test job %s not found", testJob))
+      if (!SKIP_TEST.equals("true")){
+        wrap([$class: 'AnsiColorBuildWrapper']) {
+          def gerritProjectArray = GERRIT_PROJECT.tokenize("/")
+          def gerritProject = gerritProjectArray[gerritProjectArray.size() - 1]
+          def jobsNamespace = JOBS_NAMESPACE
+          // remove plural s on the end of job namespace
+          if (JOBS_NAMESPACE[JOBS_NAMESPACE.length() - 1].equals("s")){
+            jobsNamespace = JOBS_NAMESPACE.substring(0, JOBS_NAMESPACE.length() - 1)
+          }
+          def testJob = "test-${jobsNamespace}-${gerritProject}"
+          if (_jobExists(testJob)) {
+            common.infoMsg("Test job ${testJob} found, running")
+            build job: testJob, parameters: [
+              [$class: 'StringParameterValue', name: 'GERRIT_BRANCH', value: GERRIT_BRANCH],
+              [$class: 'StringParameterValue', name: 'GERRIT_NAME', value: GERRIT_NAME],
+              [$class: 'StringParameterValue', name: 'GERRIT_HOST', value: GERRIT_HOST],
+              [$class: 'StringParameterValue', name: 'GERRIT_PORT', value: GERRIT_PORT],
+              [$class: 'StringParameterValue', name: 'GERRIT_PROJECT', value: GERRIT_PROJECT],
+              [$class: 'StringParameterValue', name: 'GERRIT_REFSPEC', value: GERRIT_REFSPEC]
+            ]
+          } else {
+            common.infoMsg("Test job ${testJob} not found")
+          }
         }
+      } else {
+        common.infoMsg("Test job skipped")
       }
     }
     stage("submit review"){