CORD-742 Read CORD app version from onos-apps/apps/pom.xml

Change-Id: Id2a9f2d1fddba1c705cbfd5db59c643637179fd5
(cherry picked from commit 829bc004526493f9079b2ef2d272aba2d2cc8f03)
diff --git a/build.gradle b/build.gradle
index 9c462da..97259c4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -35,6 +35,15 @@
     }
 }
 
+def getCordAppVersion = { ->
+    def StdOut = new ByteArrayOutputStream()
+    exec {
+        commandLine "xpath", "-q", "-e", "project/version/text()", "../../onos-apps/apps/pom.xml"
+        standardOutput = StdOut
+    }
+    return StdOut.toString().trim()
+}
+
 ext {
 
     // Upstream registry to simplify filling out the comps table below
@@ -68,6 +77,14 @@
 
     println "targetReg = $targetReg, targetTag = $targetTag"
 
+
+    // Version of the CORD apps to load into ONOS
+    cordAppVersion = project.hasProperty('cordAppVersion')
+        ? project.getProperty('cordAppVersion')
+        : getCordAppVersion()
+
+    println "CORD app version: $cordAppVersion"
+
     // Component table
     comps = [
     ]
@@ -184,6 +201,7 @@
 
     extraVars = extraVars.p("$targetReg", "deploy_docker_registry")
         .p("$targetTag", "deploy_docker_tag")
+        .p("$cordAppVersion", "cord_app_version")
 
     def skipTags = [].p(config.seedServer.skipTags)
 
@@ -228,6 +246,7 @@
 
     extraVars = extraVars.p("$targetReg", "deploy_docker_registry")
         .p("$targetTag", "deploy_docker_tag")
+        .p("$cordAppVersion", "cord_app_version")
 
     def skipTags = [].p(config.seedServer.skipTags)
 
@@ -272,6 +291,7 @@
 
     extraVars = extraVars.p("$targetReg", "deploy_docker_registry")
         .p("$targetTag", "deploy_docker_tag")
+        .p("$cordAppVersion", "cord_app_version")
 
     def skipTags = [].p(config.seedServer.skipTags)
 
@@ -316,6 +336,7 @@
 
     extraVars = extraVars.p("$targetReg", "deploy_docker_registry")
         .p("$targetTag", "deploy_docker_tag")
+        .p("$cordAppVersion", "cord_app_version")
 
     def skipTags = [].p(config.seedServer.skipTags)
 
@@ -360,6 +381,7 @@
 
     extraVars = extraVars.p("$targetReg", "deploy_docker_registry")
         .p("$targetTag", "deploy_docker_tag")
+        .p("$cordAppVersion", "cord_app_version")
 
     def skipTags = [].p(config.seedServer.skipTags)
 
@@ -417,6 +439,7 @@
 
     extraVars = extraVars.p("$targetReg", "deploy_docker_registry")
         .p("$targetTag", "deploy_docker_tag")
+        .p("$cordAppVersion", "cord_app_version")
 
     def skipTags = [].p(config.seedServer.skipTags)