LAVA: Enable job URL

This changeset allows clickable links in the build history link to be
clickable to the LAVA URL. The code breaks out the difference between
LAVA and Tuxsuite jobs so only LAVA urls are generated.

Signed-off-by: Benjamin Copeland <ben.copeland@linaro.org>
Change-Id: I5fa5d018e31f06d38410efc8454002b0ba949f38
diff --git a/jenkins/lava-submit.jpl b/jenkins/lava-submit.jpl
index 5103d31..afce141 100644
--- a/jenkins/lava-submit.jpl
+++ b/jenkins/lava-submit.jpl
@@ -58,7 +58,25 @@
       --lava-user ${LAVA_USER} --lava-token ${LAVA_TOKEN} | egrep "^JOBS"
       ''', returnStdout: true).trim()
     print("${job_ids}")
-    currentBuild.setDescription(job_ids)
+
+    def lines = job_ids.split('\n')
+    def processedLines = []
+    lines.each { line ->
+      line = line.replace('JOBS:', '').trim()
+      def tokens = line.split(',')
+      tokens = tokens.collect { token ->
+        token = token.trim()
+        if (token ==~ /^\d+$/) {
+          return "<a href='${env.LAVA_URL}/scheduler/job/${token}'>${token}</a>"
+        } else {
+          return token
+        }
+      }
+      processedLines << tokens.join(' ')
+    }
+    def finalDescription = processedLines.join('<br/>')
+    println("Setting description to: " + finalDescription)
+    currentBuild.setDescription(finalDescription)
   }
 }