[ONOS-7986]: Refactoring uses of TestON Jenkinsfile paths

Change-Id: I9f123db29de1178a4422116292b7c96b7317fad4
diff --git a/TestON/JenkinsFile/CHO_Graph_Generator b/TestON/JenkinsFile/CHO_Graph_Generator
index 26e7ca2..db65ce7 100644
--- a/TestON/JenkinsFile/CHO_Graph_Generator
+++ b/TestON/JenkinsFile/CHO_Graph_Generator
@@ -24,6 +24,7 @@
 fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
 
 fileRelated.init()
+
 // The way reading the parameters from the Jenkins.
 branches = params.ONOSbranch
 hours = params.hours
@@ -34,10 +35,11 @@
 // initialize the directory.
 
 // Script file is the R script path
-script_file = fileRelated.trendCHO
+script_file = fileRelated.rScriptPaths[ "scripts" ][ "trendCHO" ]
+
 // saving_directory is the directory that save the generate graphs.
-saving_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric5/"
-scriptDir = fileRelated.CHOScriptDir
+saving_directory = fileRelated.workspaces[ "Fabric5" ]
+scriptDir = fileRelated.rScriptPaths[ "directories" ][ "CHO" ]
 
 // create a bash script that will generate the graph
 graphScript = generateGraphScript( branchList )
@@ -54,7 +56,7 @@
     postJob()
 }
 
-saving_directory = fileRelated.jenkinsWorkspace + "postjob-Trellis-POD/"
+saving_directory = fileRelated.workspaces[ "Trellis" ]
 graphScript = generateGraphScript( branchList )
 stage( 'Generating-Graph-POD' ) {
     // This will run on TestStation-Trellis-POD node.
diff --git a/TestON/JenkinsFile/Overall_Graph_Generator b/TestON/JenkinsFile/Overall_Graph_Generator
index 6b30ed0..4eed1b3 100644
--- a/TestON/JenkinsFile/Overall_Graph_Generator
+++ b/TestON/JenkinsFile/Overall_Graph_Generator
@@ -27,9 +27,9 @@
 fileRelated.init()
 
 // set the file and directory paths.
-stat_graph_generator_file = fileRelated.histogramMultiple
-pie_graph_generator_file = fileRelated.pieMultiple
-graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-VM/"
+stat_graph_generator_file = fileRelated.rScriptPaths[ "scripts" ][ "histogramMultiple" ]
+pie_graph_generator_file = fileRelated.rScriptPaths[ "scripts" ][ "pieMultiple" ]
+graph_saved_directory = fileRelated.workspaces[ "VM" ]
 
 // init trend which will generate the pie and histogram graphs to be VM.
 funcs.initializeTrend( "VM" )
diff --git a/TestON/JenkinsFile/Trend_Graph_Generator b/TestON/JenkinsFile/Trend_Graph_Generator
index 77e57c9..fc20373 100644
--- a/TestON/JenkinsFile/Trend_Graph_Generator
+++ b/TestON/JenkinsFile/Trend_Graph_Generator
@@ -43,8 +43,8 @@
 prop[ "ONOSBranch" ] = params.ONOSbranch
 
 // set some of the paths of the file and directory
-graph_generator_file = fileRelated.trendIndividual
-graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-" + nodeCluster +
+graph_generator_file = fileRelated.rScriptPaths[ "scripts" ][ "trendIndividual" ]
+graph_saved_directory = fileRelated.workspaces[ "base" ] + "postjob-" + nodeCluster +
                         ( nodeCluster == "Fabric" ? funcs.fabricOn( prop[ "ONOSBranch" ] ) : "" ) + "/"
 
 def testsToRun = null
diff --git a/TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy b/TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy
index 6eb1061..73a8751 100644
--- a/TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy
+++ b/TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy
@@ -22,30 +22,20 @@
 // This is the dependency Jenkins script.
 // This will initialize the paths of the jenkins file and paths.
 
-// init the paths for the directory
-def initLocation(){
-    jenkinsFolder = "~/OnosSystemTest/TestON/JenkinsFile/"
-    rScriptLocation = jenkinsFolder + "wikiGraphRScripts/"
-    jenkinsWorkspace = "/var/jenkins/workspace/"
-    SCPFSpecificLocation = rScriptLocation + "SCPFspecificGraphRScripts/"
-    CHOScriptDir = "~/CHO_Jenkins_Scripts/"
-}
+import groovy.json.*
 
-// init the paths for the files.
-def initFiles(){
-    trendIndividual = rScriptLocation + "trendIndividualTest.R"
-    trendMultiple = rScriptLocation + "trendMultipleTests.R"
-    trendSCPF = rScriptLocation + "trendSCPF.R"
-    trendCHO = rScriptLocation + "trendCHO.R"
-    histogramMultiple = rScriptLocation + "histogramMultipleTestGroups.R"
-    pieMultiple = rScriptLocation + "pieMultipleTests.R"
-}
+jenkinsFiles = ""
+rScriptPaths = [:]      // paths of r script files that generate wiki graphs
+workspaces = [:]        // postjob workspaces
 
 // init both directory and file paths.
 def init(){
-    initLocation()
-    initFiles()
+    def paths_buffer = readTrusted( "TestON/JenkinsFile/dependencies/paths.json" )
+    paths_json = readJSON text: paths_buffer
+
+    jenkinsFiles = paths_json[ "jenkinsFiles" ]
+    workspaces = paths_json[ "workspaces" ]
+    rScriptPaths = paths_json[ "rScript" ]
 }
 
 return this
-
diff --git a/TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy b/TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy
index 4e185fc..452ddfc 100644
--- a/TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy
+++ b/TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy
@@ -242,7 +242,7 @@
                                          dbWhere: 'AND scale=5',
                                          y_axis: 'Latency (ms)' ]
     ]
-    graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-BM/"
+    graph_saved_directory = fileRelated.workspaces[ "BM" ]
 }
 
 def getGraphCommand( rFileName, extras, host, port, user, pass, testName, branchName, isOldFlow ){
@@ -258,7 +258,7 @@
 def generateGraph( rFileName, batch, host, port, user, pass, testName, branchName, isOldFlow ){
     //  generate the Rscript command for individual graphs
 
-    return generalFuncs.basicGraphPart( fileRelated.SCPFSpecificLocation + rFileName,
+    return generalFuncs.basicGraphPart( fileRelated.rScriptPaths[ "directories" ][ "SCPF" ] + rFileName,
                                         host, port, user, pass, testName, branchName ) +
            " " + batch + " " + usingOldFlow( isOldFlow, testName ) + graph_saved_directory
 }
@@ -268,7 +268,7 @@
     def result = ""
 
     for ( int i = 0; i < SCPF[ testName ][ 'graphTitle' ].size(); i++ ){
-        result += generalFuncs.basicGraphPart( fileRelated.trendSCPF,
+        result += generalFuncs.basicGraphPart( fileRelated.rScriptPaths[ "scripts" ][ "trendSCPF" ],
                                                host,
                                                port,
                                                user,
diff --git a/TestON/JenkinsFile/dependencies/paths.json b/TestON/JenkinsFile/dependencies/paths.json
new file mode 100644
index 0000000..87bb6c0
--- /dev/null
+++ b/TestON/JenkinsFile/dependencies/paths.json
@@ -0,0 +1,27 @@
+{
+    "jenkinsFiles": "~/OnosSystemTest/TestON/JenkinsFile/",
+    "workspaces" : {
+        "base" : "/var/jenkins/workspace/",
+        "all-pipeline-trigger" : "/var/jenkins/workspace/all-pipeline-trigger/",
+        "BM" : "/var/jenkins/workspace/postjob-BM/",
+        "VM" : "/var/jenkins/workspace/postjob-VM/",
+        "Fabric" : "/var/jenkins/workspace/postjob-Fabric/",
+        "Fabric5" : "/var/jenkins/workspace/postjob-Fabric5/",
+        "Trellis" : "/var/jenkins/workspace/postjob-Trellis-POD/"
+    },
+    "rScript": {
+        "directories": {
+            "base": "~/OnosSystemTest/TestON/JenkinsFile/wikiGraphRScripts/",
+            "SCPF": "~/OnosSystemTest/TestON/JenkinsFile/wikiGraphRScripts/SCPFspecificGraphRScripts",
+            "CHO": "~/CHO_Jenkins_Scripts"
+        },
+        "scripts": {
+            "trendIndividual": "~/OnosSystemTest/TestON/JenkinsFile/wikiGraphRScripts/trendIndividualTest.R",
+            "trendMultiple": "~/OnosSystemTest/TestON/JenkinsFile/wikiGraphRScripts/trendMultipleTests.R",
+            "trendSCPF": "~/OnosSystemTest/TestON/JenkinsFile/wikiGraphRScripts/trendSCPF.R",
+            "trendCHO": "~/OnosSystemTest/TestON/JenkinsFile/wikiGraphRScripts/trendCHO.R",
+            "histogramMultiple": "~/OnosSystemTest/TestON/JenkinsFile/wikiGraphRScripts/histogramMultipleTestGroups.R",
+            "pieMultiple": "~/OnosSystemTest/TestON/JenkinsFile/wikiGraphRScripts/pieMultipleTests.R"
+        }
+    }
+}