diff --git a/TestON/JenkinsFile/CommonJenkinsFile.groovy b/TestON/JenkinsFile/CommonJenkinsFile.groovy
index 29a5862..5ecf63d 100644
--- a/TestON/JenkinsFile/CommonJenkinsFile.groovy
+++ b/TestON/JenkinsFile/CommonJenkinsFile.groovy
@@ -18,8 +18,11 @@
 //     You should have received a copy of the GNU General Public License
 //     along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 
+import groovy.time.TimeCategory
+import groovy.time.TimeDuration
+
 // read the dependency files
-funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
+graphs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsGraphs.groovy' )
 test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
 fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
 SCPFfuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy' )
@@ -29,8 +32,13 @@
 testsToRun = null
 testsToRunStrList = null
 branch = null
+branchWithPrefix = null
 start = null
+nodeLabel = null
 testStation = null
+testsOverride = null
+isGraphOnly = false
+isSCPF = false
 testsFromList = [:]
 graphPaths = [:]
 pipeline = [:]
@@ -50,37 +58,57 @@
     readParams()
 
     if ( category == "SCPF" ){
-        // SCPF needs to obtain properties earlier
-        funcs.initialize( category, testStation, nodeLabel, SCPFfuncs );
-        prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
-
+        isSCPF = true
         SCPFfuncs.init()
-        isOldFlow = prop[ "isOldFlow" ] == "true"
+        graphs.initialize( category, SCPFfuncs );
+        prop = getProperties()
+        isOldFlow = ( prop[ "isOldFlow" ] == "true" )
         SCPFfuncs.oldFlowRuleCheck( isOldFlow, prop[ "ONOSBranch" ] )
-    } else if ( category == "SR" ){
-        funcs.initialize( category, testStation, nodeLabel );
-        // get the name of the Jenkins job.
-        jobName = env.JOB_NAME
-        prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
     } else {
-        funcs.initialize( category, testStation, nodeLabel );
-        prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
+        isSCPF = false
+        graphs.initialize()
+        prop = getProperties()
     }
 
     // get the list of the test and init branch to it.
     testsFromList = test_list.getTestsFromCategory( category )
 
     initGraphPaths()
+    tokenizeTokens = "\n;, "
 
-    testsToRunStrList = funcs.getTestsToRun( prop[ "Tests" ] )
+    if ( testsOverride == "" || testsOverride == null ){
+        testsToRunStrList = prop[ "Tests" ].tokenize( tokenizeTokens )
+    } else {
+        testsToRunStrList = testsOverride.tokenize( tokenizeTokens )
+    }
     testsToRun = test_list.getTestsFromStringList( testsToRunStrList )
 }
 
 def readParams(){
     category = params.Category       // "FUNC", "HA", "USECASE", etc.
     branch = params.Branch           // "1.15", "2.1", "master", etc.
+    branchWithPrefix = test_list.addPrefixToBranch( branch )
     testStation = params.TestStation // "TestStation-BMs", etc.
     nodeLabel = params.NodeLabel     // "BM", "VM", "Fabric-1.x", etc.
+    testsOverride = params.TestsOverride // "FUNCflow, FUNCintent, [...]", overrides property file
+    isGraphOnly = params.OnlyRefreshGraphs // true or false
+}
+
+def getProperties(){
+    // get the properties of the test by reading the TestONOS.property
+
+    filePath = '''/var/jenkins/TestONOS-''' + category + '''-''' + branchWithPrefix + '''.property'''
+
+    node( testStation ) {
+        return readProperties( file: filePath )
+    }
+}
+
+def getCurrentTime(){
+    // get time of the PST zone.
+
+    TimeZone.setDefault( TimeZone.getTimeZone( 'PST' ) )
+    return new Date()
 }
 
 def initGraphPaths(){
@@ -99,15 +127,21 @@
 def runTests(){
     // run the test sequentially and save the function into the dictionary.
     for ( String test : testsToRun.keySet() ){
-        def toBeRun = test
-        def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
-        def pureTestName = ( testsToRun[ test ].containsKey( "test" ) ? testsToRun[ test ][ "test" ].split().head() : test )
-        pipeline[ stepName ] = funcs.runTest( test, toBeRun, prop, pureTestName, false,
-                                           testsToRun, graphPaths[ "trendIndividual" ], graphPaths[ "saveDirectory" ] )
+        toBeRun = test
+        stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
+        pureTestName = ( testsToRun[ test ].containsKey( "test" ) ? testsToRun[ test ][ "test" ].split().head() : test )
+        pipeline[ stepName ] = runTest( test,
+                                        toBeRun,
+                                        prop,
+                                        pureTestName,
+                                        isGraphOnly,
+                                        testsToRun,
+                                        graphPaths[ "trendIndividual" ],
+                                        graphPaths[ "saveDirectory" ] )
     }
 
     // get the start time of the test.
-    start = funcs.getCurrentTime()
+    start = getCurrentTime()
 
     // run the tests sequentially.
     for ( test in pipeline.keySet() ){
@@ -115,14 +149,272 @@
     }
 }
 
+def initTest(){
+    return '''#!/bin/bash -l
+        set -i # interactive
+        set +e
+        shopt -s expand_aliases # expand alias in non-interactive mode
+        export PYTHONUNBUFFERED=1
+        ifconfig
+        echo "ONOS Branch is: $ONOSBranch"
+        echo "TestON Branch is: $TestONBranch"
+        echo "Test date: "
+        date
+        cd ~
+        export PATH=$PATH:onos/tools/test/bin
+        timeout 240 stc shutdown | head -100
+        timeout 240 stc teardown | head -100
+        timeout 240 stc shutdown | head -100
+        cd ~/OnosSystemTest/TestON/bin
+        git log | head
+        ./cleanup.sh -f || true
+        '''
+}
+
+def runTestCli_py( testName, testCategory ){
+    // Bash script that will run the test.
+    // testName : name of the test
+    // testCategory : (SR,FUNC ... )
+
+    return '''cd ~/OnosSystemTest/TestON/bin
+           ./cli.py run ''' +
+           testName +
+           ''' --params GRAPH/nodeCluster=''' + nodeLabel
+}
+
+def concludeRunTest(){
+    return '''cd ~/OnosSystemTest/TestON/bin
+              ./cleanup.sh -f || true
+              # cleanup config changes
+              cd ~/onos/tools/package/config
+              git clean -df'''
+}
+
+def copyLogs(){
+    // bash script to copy the logs and other necessary element for SR tests.
+
+    result = ""
+    if ( category == "SR" ){
+        result = '''
+      sudo rm /var/jenkins/workspace/SR-log-${WikiPrefix}/*
+      sudo cp *karaf.log.* /var/jenkins/workspace/SR-log-${WikiPrefix}/
+      sudo cp *Flows* /var/jenkins/workspace/SR-log-${WikiPrefix}/
+      sudo cp *Groups* /var/jenkins/workspace/SR-log-${WikiPrefix}/
+      sudo cp *.tar.gz /var/jenkins/workspace/SR-log-${WikiPrefix}/
+      sudo cp t3-* /var/jenkins/workspace/SR-log-${WikiPrefix}/
+      '''
+    }
+    return result
+}
+
+def cleanAndCopyFiles( testName ){
+    // clean up some files that were in the folder and copy the new files from the log
+    // testName : name of the test
+
+    return '''#!/bin/bash -i
+        set +e
+        echo "ONOS Branch is: ${ONOSBranch}"
+        echo "TestON Branch is: ${TestONBranch}"
+        echo "Job name is: "''' + testName + '''
+        echo "Workspace is: ${WORKSPACE}/"
+        echo "Wiki page to post is: ${WikiPrefix}-"
+        # remove any leftover files from previous tests
+        sudo rm ${WORKSPACE}/*Wiki.txt
+        sudo rm ${WORKSPACE}/*Summary.txt
+        sudo rm ${WORKSPACE}/*Result.txt
+        sudo rm ${WORKSPACE}/*Alarm.txt || true
+        sudo rm ${WORKSPACE}/*.csv
+        #copy files to workspace
+        cd `ls -t ~/OnosSystemTest/TestON/logs/*/ | head -1 | sed 's/://'`
+        ''' + copyLogs() + '''
+        sudo cp *.txt ${WORKSPACE}/
+        sudo cp *.csv ${WORKSPACE}/
+        cd ${WORKSPACE}/
+        for i in *.csv
+            do mv "$i" "$WikiPrefix"-"$i"
+        done
+        ls -al
+        cd '''
+}
+
+def fetchLogs( testName ){
+    // fetch the logs of onos from onos nodes to onos System Test logs
+    // testName: name of the test
+
+    return '''#!/bin/bash
+  set +e
+  cd ~/OnosSystemTest/TestON/logs
+  echo "TestON test name is: "''' + testName + '''
+  TestONlogDir=$(ls -t | grep ${TEST_NAME}_  |head -1)
+  echo "########################################################################################"
+  echo "#####  copying ONOS logs from all nodes to TestON/logs directory: ${TestONlogDir}"
+  echo "########################################################################################"
+  cd $TestONlogDir
+  if [ $? -eq 1 ]
+  then
+      echo "Job name does not match any test suite name to move log!"
+  else
+      pwd
+      for i in $OC{1..7}; do onos-fetch-logs $i || echo log does not exist for onos $i; done
+      for i in $OC{1..7}; do atomix-fetch-logs $i || echo log does not exist for atomix $i; done
+  fi
+  cd'''
+}
+
+def publishToConfluence( isManualRun, isPostResult, wikiLink, file ){
+    // publish HTML script to wiki confluence
+    // isManualRun : string "true" "false"
+    // isPostResult : string "true" "false"
+    // wikiLink : link of the wiki page to publish
+    // file : name of the file to be published
+
+    if ( isPostingResult( isManualRun, isPostResult ) ){
+        publishConfluence siteName: 'wiki.onosproject.org', pageName: wikiLink, spaceName: 'ONOS',
+                          attachArchivedArtifacts: true, buildIfUnstable: true,
+                          editorList: [ confluenceWritePage( confluenceFile( file ) ) ]
+    }
+}
+
+def postLogs( testName, prefix ){
+    // posting logs of the onos jobs specifically SR tests
+    // testName : name of the test
+    // prefix : branch prefix ( master, 2.1, 1.15 ... )
+
+    resultURL = ""
+    if ( category == "SR" ){
+        def post = build job: "SR-log-" + prefix, propagate: false
+        resultURL = post.getAbsoluteUrl()
+    }
+    return resultURL
+}
+
+def analyzeResult( prop, workSpace, pureTestName, testName, resultURL, wikiLink, isSCPF ){
+    // analyzing the result of the test and send to slack if any abnormal result is logged.
+    // prop : property dictionary
+    // workSpace : workSpace where the result file is saved
+    // pureTestName : TestON name of the test
+    // testName : Jenkins name of the test. Example: SCPFflowTPFobj
+    // resultURL : url for the logs for SR tests. Will not be posted if it is empty
+    // wikiLink : link of the wiki page where the result was posted
+    // isSCPF : Check if it is SCPF. If so, it won't post the wiki link.
+
+    node( testStation ) {
+        def alarmFile = workSpace + "/" + pureTestName + "Alarm.txt"
+        if ( fileExists( alarmFile ) ) {
+            def alarmContents = readFile( alarmFile )
+            slackSend( channel: "#jenkins-related",
+                       color: "FF0000",
+                       message: "[" + prop[ "ONOSBranch" ] + "]" + testName + " : triggered alarms:\n" +
+                                alarmContents + "\n" +
+                                "[TestON log] : \n" +
+                                "https://jenkins.onosproject.org/blue/organizations/jenkins/${ env.JOB_NAME }/detail/${ env.JOB_NAME }/${ env.BUILD_NUMBER }/pipeline" +
+                                ( isSCPF ? "" : ( "\n[Result on Wiki] : \n" +
+                                                  "https://wiki.onosproject.org/display/ONOS/" +
+                                                  wikiLink.replaceAll( "\\s", "+" ) ) ) +
+                                ( resultURL != "" ? ( "\n[Karaf log] : \n" +
+                                                      resultURL + "artifact/" ) : "" ),
+                       teamDomain: 'onosproject' )
+            throw new Exception( "Abnormal test result." )
+        }
+        else {
+            print "Test results are OK."
+        }
+    }
+}
+
+def runTest( testName, toBeRun, prop, pureTestName, graphOnly, testCategory, graph_generator_file,
+             graph_saved_directory ){
+    // run the test on the machine that contains all the steps : init and run test, copy files, publish result ...
+    // testName : name of the test in Jenkins
+    // toBeRun : boolean value whether the test will be run or not. If not, it won't be run but shows up with empty
+    //           result on pipeline view
+    // prop : dictionary property on the machine
+    // pureTestName : Pure name of the test. ( ex. pureTestName of SCPFflowTpFobj will be SCPFflowTp )
+    // graphOnly : check if it is generating graph job. If so, it will only generate the generating graph part
+    // testCategory : Map for the test suit ( SCPF, SR, FUNC, ... ) which contains information about the tests
+    // graph_generator_file : Rscript file with the full path.
+    // graph_saved_directory : where the generated graph will be saved to.
+
+    return {
+        catchError {
+            stage( testName ) {
+                if ( toBeRun ){
+                    def workSpace = "/var/jenkins/workspace/" + testName
+                    def fileContents = ""
+                    node( testStation ) {
+                        withEnv( [ 'ONOSBranch=' + prop[ "ONOSBranch" ],
+                                   'ONOSJAVAOPTS=' + prop[ "ONOSJAVAOPTS" ],
+                                   'TestONBranch=' + prop[ "TestONBranch" ],
+                                   'ONOSTag=' + prop[ "ONOSTag" ],
+                                   'WikiPrefix=' + prop[ "WikiPrefix" ],
+                                   'WORKSPACE=' + workSpace ] ) {
+                            if ( !graphOnly ){
+                                if ( isSCPF ){
+                                    // Remove the old database file
+                                    sh SCPFfuncs.cleanupDatabaseFile( testName )
+                                }
+                                sh script: initTest(), label: "Test Initialization: stc shutdown; stc teardown; ./cleanup.sh"
+                                catchError{
+                                    sh script: runTestCli_py( testName, testCategory ), label: ( "Run Test: ./cli.py run " + testName )
+                                }
+                                catchError{
+                                    sh script: concludeRunTest(), label: "Conclude Running Test: ./cleanup.sh; git clean -df"
+                                }
+                                catchError{
+                                    // For the Wiki page
+                                    sh script: cleanAndCopyFiles( pureTestName ), label: "Clean and Copy Files"
+                                }
+                            }
+                            graphs.databaseAndGraph( prop, testName, pureTestName, graphOnly,
+                                                    graph_generator_file, graph_saved_directory )
+                            if ( !graphOnly ){
+                                sh script: fetchLogs( pureTestName ), label: "Fetch Logs"
+                                if ( !isSCPF ){
+                                    publishToConfluence( prop[ "manualRun" ], prop[ "postResult" ],
+                                                         prop[ "WikiPrefix" ] + "-" + testCategory[ testName ][ 'wikiName' ],
+                                                         workSpace + "/" + testCategory[ testName ][ 'wikiFile' ] )
+                                }
+                            }
+                        }
+                    }
+                    graphs.postResult( prop, graphOnly, nodeLabel )
+                    if ( !graphOnly ){
+                        def resultURL = postLogs( testName, prop[ "WikiPrefix" ] )
+                        analyzeResult( prop, workSpace, pureTestName, testName, resultURL,
+                                       isSCPF ? "" : testCategory[ testName ][ 'wikiName' ],
+                                       isSCPF )
+                    }
+                }
+            }
+        }
+    }
+}
+
 def generateGraphs(){
     if ( category != "SCPF" ){
         // generate the overall graph of the non SCPF tests.
-        funcs.generateOverallGraph( prop, testsToRun, graphPaths[ "saveDirectory" ] )
+        graphs.generateOverallGraph( prop, testsToRun, graphPaths[ "saveDirectory" ], nodeLabel, category )
     }
 }
 
 def sendToSlack(){
-    // send the notification to Slack that running tests ended.
-    funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] )
+    // send the result of the test to the slack when it is not manually running.
+    // start : start time of the test
+    // isManualRun : string that is whether "false" or "true"
+    // branch : branch of the onos.
+
+    try {
+        if ( prop[ "manualRun" ] == "false" ){
+            end = getCurrentTime()
+            TimeDuration duration = TimeCategory.minus( end, start )
+            // FIXME: for now we disable notifications of normal test results
+            /*
+            slackSend( color: "#5816EE",
+                       message: category + "-" + prop[ "WikiPrefix" ] + " tests ended at: " + end.toString() +
+                                "\nTime took : " + duration )
+            */
+        }
+    }
+    catch ( all ){
+    }
 }
diff --git a/TestON/JenkinsFile/JenkinsfileTrigger b/TestON/JenkinsFile/JenkinsfileTrigger
deleted file mode 100644
index 28d6940..0000000
--- a/TestON/JenkinsFile/JenkinsfileTrigger
+++ /dev/null
@@ -1,62 +0,0 @@
-#!groovy
-// Copyright 2017 Open Networking Foundation (ONF)
-//
-// Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
-// the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
-// or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
-//
-//     TestON is free software: you can redistribute it and/or modify
-//     it under the terms of the GNU General Public License as published by
-//     the Free Software Foundation, either version 2 of the License, or
-//     (at your option) any later version.
-//
-//     TestON is distributed in the hope that it will be useful,
-//     but WITHOUT ANY WARRANTY; without even the implied warranty of
-//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//     GNU General Public License for more details.
-//
-//     You should have received a copy of the GNU General Public License
-//     along with TestON.  If not, see <http://www.gnu.org/licenses/>.
-
-// This is the Jenkins script for all-pipeline-trigger
-
-// read the dependency functions
-funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
-
-// get current time and send the notification of starting the test.
-def now = funcs.getCurrentTime()
-print now.toString()
-
-// read the passed parameters from the Jenkins.
-machines = params.machines
-manually_run = params.manual_run
-// FIXME: for now we disable any other slack notifications excpet alarms
-/*
-if ( !manually_run ){
-    slackSend( color: '#03CD9F',
-               message: ":sparkles:" * 16 + "\n" +
-                        "Starting tests on : " + now.toString() +
-                        "\n" + ":sparkles:" * 16 )
-}
-*/
-
-// store the list of the machines into the dictionary.
-machineList = machines.tokenize( "\n;, " )
-machineOn = [ : ]
-
-// save the triggering job function as a dictionary.
-for ( machine in machineList ){
-    print( machine )
-    machineOn[ machine ] = triggerJob( machine )
-}
-
-// run the triggering jobs concurrently.
-parallel machineOn
-
-// function that will trigger the specific jobs from current pipeline.
-def triggerJob( on ){
-    return {
-        jobToRun = on + "-pipeline-trigger"
-        build job: jobToRun, propagate: false
-    }
-}
diff --git a/TestON/JenkinsFile/MasterTrigger.groovy b/TestON/JenkinsFile/MasterTrigger.groovy
index 372efc6..c095810 100644
--- a/TestON/JenkinsFile/MasterTrigger.groovy
+++ b/TestON/JenkinsFile/MasterTrigger.groovy
@@ -20,9 +20,11 @@
 
 // This is the Jenkins script for master-trigger
 
+import groovy.time.TimeCategory
+import groovy.time.TimeDuration
+
 // set the functions of the dependencies.
-funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
-triggerFuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/TriggerFuncs.groovy' )
+graphs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsGraphs.groovy' )
 fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
 test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
 
@@ -86,7 +88,7 @@
     manually_run = params.manual_run
     onos_tag = params.ONOSTag
     branchesParam = params.branches
-    isOldFlow = params.isOldFlow
+    isOldFlow = true // hardcoding to true since we are always using oldFlow.
     testsParam = params.Tests
     isFabric = params.isFabric
     simulateDay = params.simulate_day
@@ -95,7 +97,7 @@
 // Set tests based on day of week
 def initDates(){
     echo "-> initDates()"
-    now = funcs.getCurrentTime()
+    now = getCurrentTime()
     dayMap = [ ( Calendar.MONDAY )    : "mon",
                ( Calendar.TUESDAY )   : "tue",
                ( Calendar.WEDNESDAY ) : "wed",
@@ -119,6 +121,13 @@
     }
 }
 
+def getCurrentTime(){
+    // get time of the PST zone.
+
+    TimeZone.setDefault( TimeZone.getTimeZone( 'PST' ) )
+    return new Date()
+}
+
 // gets ONOS branches from params or string parameter
 def getONOSBranches(){
     echo "-> getONOSBranches()"
@@ -178,13 +187,204 @@
 def postToSlackTestsToRun(){
     slackSend( color: '#FFD988',
                message: "Tests to be run this weekdays : \n" +
-                        triggerFuncs.printDaysForTest() )
+                        printDaysForTest() )
+}
+
+def printDaysForTest(){
+    // Print the days for what test has.
+    AllTheTests = test_list.getAllTests()
+
+    result = ""
+    for ( String test in AllTheTests.keySet() ){
+        result += test + ": ["
+        test_schedule = AllTheTests[ test ][ "schedules" ]
+        for ( String sch_dict in test_schedule ){
+            for ( String day in test_list.convertScheduleKeyToDays( sch_dict[ "branch" ] ) ){
+                result += day + " "
+            }
+        }
+        result += "]\n"
+    }
+    return result
 }
 
 // *********
 // Run Tests
 // *********
 
+def tagCheck( onos_tag, onos_branch ){
+    // check the tag for onos if it is not empty
+
+    result = "git checkout "
+    if ( onos_tag == "" ){
+        //create new local branch
+        result += onos_branch
+    }
+    else {
+        //checkout the tag
+        result += onos_tag
+    }
+    return result
+}
+
+def preSetup( onos_branch, test_branch, onos_tag, isManual ){
+    // pre setup part which will clean up and checkout to corresponding branch.
+
+    result = ""
+    if ( !isManual ){
+        result = '''echo -e "\n#####  Set TestON Branch #####"
+        echo "TestON Branch is set on: ''' + test_branch + '''"
+        cd ~/OnosSystemTest/
+        git checkout HEAD~1      # Make sure you aren't pn a branch
+        git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
+        git branch -D ''' + test_branch + ''' # just in case there are local changes. This will normally result in a branch not found error
+        git clean -df # clean any local files
+        git fetch --all # update all caches from remotes
+        git reset --hard origin/''' + test_branch + '''  # force local index to match remote branch
+        git clean -df # clean any local files
+        git checkout ''' + test_branch + ''' #create new local branch
+        git branch
+        git log -1 --decorate
+        echo -e "\n#####  Set ONOS Branch #####"
+        echo "ONOS Branch is set on: ''' + onos_branch + '''"
+        echo -e "\n #### check karaf version ######"
+        env |grep karaf
+        cd ~/onos
+        git checkout HEAD~1      # Make sure you aren't pn a branch
+        git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
+        git branch -D ''' + onos_branch + ''' # just incase there are local changes. This will normally result in a branch not found error
+        git clean -df # clean any local files
+        git fetch --all # update all caches from remotes
+        git reset --hard origin/''' + onos_branch + '''  # force local index to match remote branch
+        git clean -df # clean any local files
+        rm -rf buck-out
+        rm -rf bazel-*
+        ''' + tagCheck( onos_tag, onos_branch ) + '''
+        git branch
+        git log -1 --decorate
+        echo -e "\n##### set jvm heap size to 8G #####"
+        echo ${ONOSJAVAOPTS}
+        inserted_line="export JAVA_OPTS=\"\${ONOSJAVAOPTS}\""
+        sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service
+        echo "##### Check onos-service setting..... #####"
+        cat ~/onos/tools/package/bin/onos-service
+        export JAVA_HOME=/usr/lib/jvm/java-8-oracle'''
+    } else {
+        result = '''echo "Since this is a manual run, we'll use the current ONOS and TestON branch:"
+                    echo "ONOS branch:"
+                    cd ~/OnosSystemTest/
+                    git branch
+                    echo "TestON branch:"
+                    cd ~/TestON/
+                    git branch'''
+    }
+    return result
+}
+
+def postSetup( onos_branch, test_branch, onos_tag, isManual ){
+    // setup that will build ONOS
+
+    result = ""
+    if ( !isManual ){
+        result = '''echo -e "Installing bazel"
+        cd ~
+        rm -rf ci-management
+        git clone https://gerrit.onosproject.org/ci-management
+        cd ci-management/jjb/onos/
+        export GERRIT_BRANCH="''' + onos_branch + '''"
+        chmod +x install-bazel.sh
+        ./install-bazel.sh
+        '''
+    } else {
+        result = '''echo -e "Since this is a manual run, we will not install Bazel."'''
+    }
+    return result
+}
+
+def generateKey(){
+    // generate cluster-key of the onos
+
+    try {
+        sh script: '''
+        #!/bin/bash -l
+        set +e
+        . ~/.bashrc
+        env
+        onos-push-bits-through-proxy
+        onos-gen-cluster-key -f
+        ''', label: "Generate Cluster Key", returnStdout: false
+    } catch ( all ){
+    }
+}
+
+// Initialize the environment Setup for the onos and OnosSystemTest
+def envSetup( onos_branch, test_branch, onos_tag, jobOn, manuallyRun, nodeLabel ){
+    // to setup the environment using the bash script
+    stage( "Environment Setup: " + onos_branch + "-" + nodeLabel + "-" + jobOn ) {
+        // after env: ''' + borrow_mn( jobOn ) + '''
+        sh script: '''#!/bin/bash -l
+        set +e
+        . ~/.bashrc
+        env
+        ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun ), label: "Repo Setup", returnStdout: false
+        sh script: postSetup( onos_branch, test_branch, onos_tag, manuallyRun ), label: "Install Bazel", returnStdout: false
+        generateKey()
+    }
+}
+
+// export Environment properties.
+def exportEnvProperty( onos_branch, test_branch, jobOn, wiki, tests, postResult, manually_run, onosTag, isOldFlow, nodeLabel ){
+    // export environment properties to the machine.
+
+    filePath = "/var/jenkins/TestONOS-" + jobOn + "-" + onos_branch + ".property"
+
+    stage( "Property Export: " + onos_branch + "-" + nodeLabel + "-" + jobOn ) {
+        sh script: '''
+            echo "ONOSBranch=''' + onos_branch + '''" > ''' + filePath + '''
+            echo "TestONBranch=''' + test_branch + '''" >> ''' + filePath + '''
+            echo "ONOSTag=''' + onosTag + '''" >> ''' + filePath + '''
+            echo "WikiPrefix=''' + wiki + '''" >> ''' + filePath + '''
+            echo "ONOSJAVAOPTS=''' + env.ONOSJAVAOPTS + '''" >> ''' + filePath + '''
+            echo "Tests=''' + tests + '''" >> ''' + filePath + '''
+            echo "postResult=''' + postResult + '''" >> ''' + filePath + '''
+            echo "manualRun=''' + manually_run + '''" >> ''' + filePath + '''
+            echo "isOldFlow=''' + isOldFlow + '''" >> ''' + filePath + '''
+        ''', label: "Exporting Property File: " + filePath
+    }
+}
+
+def trigger( branch, tests, nodeLabel, jobOn, manuallyRun, onosTag ){
+    // triggering function that will setup the environment and determine which pipeline to trigger
+
+    println "Job name: " + jobOn + "-pipeline-" + ( manuallyRun ? "manually" : branch )
+    def wiki = branch
+    def onos_branch = test_list.addPrefixToBranch( branch )
+    def test_branch = test_list.addPrefixToBranch( branch )
+    assignedNode = null
+    node( label: nodeLabel ) {
+
+        envSetup( onos_branch, test_branch, onosTag, jobOn, manuallyRun, nodeLabel )
+        exportEnvProperty( onos_branch, test_branch, jobOn, wiki, tests, post_result, manuallyRun, onosTag, isOldFlow, nodeLabel )
+        assignedNode = env.NODE_NAME
+    }
+
+    jobToRun = jobOn + "-pipeline-" + ( manuallyRun ? "manually" : wiki )
+    build job: jobToRun, propagate: false, parameters: [ [ $class: 'StringParameterValue', name: 'Category', value: jobOn ],
+                                                         [ $class: 'StringParameterValue', name: 'Branch', value: branch ],
+                                                         [ $class: 'StringParameterValue', name: 'TestStation', value: assignedNode ],
+                                                         [ $class: 'StringParameterValue', name: 'NodeLabel', value: nodeLabel ] ]
+}
+
+def trigger_pipeline( branch, tests, nodeLabel, jobOn, manuallyRun, onosTag ){
+    // nodeLabel : nodeLabel from tests.json
+    // jobOn : "SCPF" or "USECASE" or "FUNC" or "HA"
+    // this will return the function by wrapping them up with return{} to prevent them to be
+    // executed once this function is called to assign to specific variable.
+    return {
+        trigger( branch, tests, nodeLabel, jobOn, manuallyRun, onosTag )
+    }
+}
+
 def generateRunList(){
     runList = [:]
     validSchedules = test_list.getValidSchedules( day )
@@ -214,7 +414,7 @@
                 echo "TESTS: " + filteredList
                 if ( filteredList != [:] ){
                     exeTestList = test_list.getTestListAsString( filteredList )
-                    runList.put( branch + "-" + nodeLabel + "-" + category, triggerFuncs.trigger_pipeline( branch, exeTestList, nodeLabel, category, manually_run, onos_tag ) )
+                    runList.put( branch + "-" + nodeLabel + "-" + category, trigger_pipeline( branch, exeTestList, nodeLabel, category, manually_run, onos_tag ) )
                 }
 
             }
@@ -237,7 +437,7 @@
     // If it is automated running, it will generate the stats graph on VM.
     if ( !manually_run ){
         for ( String b in onos_branches ){
-            funcs.generateStatGraph( "TestStation-VMs",
+            graphs.generateStatGraph( "TestStation-VMs",
                                      test_list.addPrefixToBranch( b ),
                                      graphPaths[ "histogramMultiple" ],
                                      graphPaths[ "pieMultiple" ],
diff --git a/TestON/JenkinsFile/Overall_Graph_Generator b/TestON/JenkinsFile/Overall_Graph_Generator
index 4eed1b3..8e46c7c 100644
--- a/TestON/JenkinsFile/Overall_Graph_Generator
+++ b/TestON/JenkinsFile/Overall_Graph_Generator
@@ -21,7 +21,7 @@
 // This is the Jenkins script for manual-graph-generator-overall
 
 // read the dependency functions.
-funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
+graphs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsGraphs.groovy' )
 fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
 
 fileRelated.init()
@@ -31,15 +31,12 @@
 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" )
-
 onos_branch = params.ONOSbranch
 
 // generate the graph and post the result on TestStation-VMs. Right now, all the pie and histograms are saved
 // on VM.
-funcs.generateStatGraph( "TestStation-VMs",
+graphs.generateStatGraph( "TestStation-VMs",
                          onos_branch,
                          stat_graph_generator_file,
                          pie_graph_generator_file,
-                         graph_saved_directory )
+                         graph_saved_directory, "VM" )
diff --git a/TestON/JenkinsFile/SCPF_Graph_Generator b/TestON/JenkinsFile/SCPF_Graph_Generator
deleted file mode 100644
index d120911..0000000
--- a/TestON/JenkinsFile/SCPF_Graph_Generator
+++ /dev/null
@@ -1,53 +0,0 @@
-#!groovy
-// Copyright 2017 Open Networking Foundation (ONF)
-//
-// Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
-// the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
-// or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
-//
-//     TestON is free software: you can redistribute it and/or modify
-//     it under the terms of the GNU General Public License as published by
-//     the Free Software Foundation, either version 2 of the License, or
-//     (at your option) any later version.
-//
-//     TestON is distributed in the hope that it will be useful,
-//     but WITHOUT ANY WARRANTY; without even the implied warranty of
-//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//     GNU General Public License for more details.
-//
-//     You should have received a copy of the GNU General Public License
-//     along with TestON.  If not, see <http://www.gnu.org/licenses/>.
-
-// This is the Jenkins script for manual-graph-generator-SCPF
-
-// read and set the functions from dependencies.
-SCPFfuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy' )
-SCPFfuncs.init()
-funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
-funcs.initialize( "SCPF", "TestStation-BMs", "BM", SCPFfuncs );
-
-def prop = null
-prop = funcs.getProperties( "SCPF", params.ONOSbranch )
-
-// get the variables from the Jenkins parameters.
-def Tests = params.Test
-isOldFlow = params.isOldFlow
-prop[ "ONOSBranch" ] = params.ONOSbranch
-
-SCPFfuncs.oldFlowRuleCheck( isOldFlow, prop[ "ONOSBranch" ] )
-
-def testsToRun = null
-testsToRun = funcs.getTestsToRun( Tests )
-
-// pureTestName is because we don't want 'WFobj' to be used for test name.
-def tests = [ : ]
-for ( String test : testsToRun ){
-    println test
-    pureTestName = test.replaceAll( "WithFlowObj", "" )
-    tests[ test ] = funcs.runTest( test, true, prop, pureTestName, true, [ ], "", "" )
-}
-
-// generate the graphs sequentially.
-for ( test in tests.keySet() ){
-    tests[ test ].call()
-}
diff --git a/TestON/JenkinsFile/Trend_Graph_Generator b/TestON/JenkinsFile/Trend_Graph_Generator
deleted file mode 100644
index fc20373..0000000
--- a/TestON/JenkinsFile/Trend_Graph_Generator
+++ /dev/null
@@ -1,63 +0,0 @@
-#!groovy
-// Copyright 2017 Open Networking Foundation (ONF)
-//
-// Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
-// the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
-// or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
-//
-//     TestON is free software: you can redistribute it and/or modify
-//     it under the terms of the GNU General Public License as published by
-//     the Free Software Foundation, either version 2 of the License, or
-//     (at your option) any later version.
-//
-//     TestON is distributed in the hope that it will be useful,
-//     but WITHOUT ANY WARRANTY; without even the implied warranty of
-//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//     GNU General Public License for more details.
-//
-//     You should have received a copy of the GNU General Public License
-//     along with TestON.  If not, see <http://www.gnu.org/licenses/>.
-
-// This is the Jenkins script for manual-graph-generator-trend
-
-// read the dependency functions
-funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
-fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
-
-fileRelated.init()
-
-// read the node cluster ( VM or BM or Fabrics ) from the Jenkins job.
-nodeCluster = params.NodeCluster
-
-funcs.initializeTrend( nodeCluster )
-
-// do additional check for Fabric since it will be different depends on which branch it is running on.
-if ( nodeCluster == "Fabric" ){
-    funcs.additionalInitForSR( params.ONOSbranch )
-}
-def prop = null
-prop = funcs.getProperties( "FUNC" )
-
-// get the list of the tests from the parameters.
-def Tests = params.Test
-prop[ "ONOSBranch" ] = params.ONOSbranch
-
-// set some of the paths of the file and directory
-graph_generator_file = fileRelated.rScriptPaths[ "scripts" ][ "trendIndividual" ]
-graph_saved_directory = fileRelated.workspaces[ "base" ] + "postjob-" + nodeCluster +
-                        ( nodeCluster == "Fabric" ? funcs.fabricOn( prop[ "ONOSBranch" ] ) : "" ) + "/"
-
-def testsToRun = null
-testsToRun = funcs.getTestsToRun( Tests )
-
-// set functions into the dictionary.
-def tests = [ : ]
-for ( String test : testsToRun ){
-    println test
-    def pureTestName = test.split().head()
-    tests[ test ] = funcs.runTest( test, true, prop, pureTestName, true, [ ], graph_generator_file, graph_saved_directory )
-}
-
-for ( test in tests.keySet() ){
-    tests[ test ].call()
-}
diff --git a/TestON/JenkinsFile/dependencies/GeneralFuncs.groovy b/TestON/JenkinsFile/dependencies/GeneralFuncs.groovy
deleted file mode 100644
index 4c6f021..0000000
--- a/TestON/JenkinsFile/dependencies/GeneralFuncs.groovy
+++ /dev/null
@@ -1,43 +0,0 @@
-#!groovy
-// Copyright 2017 Open Networking Foundation (ONF)
-//
-// Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
-// the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
-// or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
-//
-//     TestON is free software: you can redistribute it and/or modify
-//     it under the terms of the GNU General Public License as published by
-//     the Free Software Foundation, either version 2 of the License, or
-//     (at your option) any later version.
-//
-//     TestON is distributed in the hope that it will be useful,
-//     but WITHOUT ANY WARRANTY; without even the implied warranty of
-//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//     GNU General Public License for more details.
-//
-//     You should have received a copy of the GNU General Public License
-//     along with TestON.  If not, see <http://www.gnu.org/licenses/>.
-
-// This is the dependency Jenkins script.
-// it has some general functionality of making database command, basic graph part, and get list of the test
-
-// make the init part of the database command
-def database_command_create( pass, host, port, user ){
-    return pass + "|psql --host=" + host + " --port=" + port + " --username=" + user + " --password --dbname onostest -c "
-}
-
-// make the basic graph part for the Rscript
-def basicGraphPart( rFileName, host, port, user, pass, subject, branchName ){
-    return " Rscript " + rFileName + " " + host + " " + port + " " + user + " " + pass + " " + subject + " " + branchName
-}
-
-// get the list of the test as dictionary then return as a string
-def getTestList( tests ){
-    def list = ""
-    for ( String test : tests.keySet() ){
-        list += test + ","
-    }
-    return list[ 0..-2 ]
-}
-
-return this
diff --git a/TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy b/TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy
deleted file mode 100644
index 26e846c..0000000
--- a/TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy
+++ /dev/null
@@ -1,521 +0,0 @@
-#!groovy
-// Copyright 2017 Open Networking Foundation (ONF)
-//
-// Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
-// the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
-// or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
-//
-//     TestON is free software: you can redistribute it and/or modify
-//     it under the terms of the GNU General Public License as published by
-//     the Free Software Foundation, either version 2 of the License, or
-//     (at your option) any later version.
-//
-//     TestON is distributed in the hope that it will be useful,
-//     but WITHOUT ANY WARRANTY; without even the implied warranty of
-//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//     GNU General Public License for more details.
-//
-//     You should have received a copy of the GNU General Public License
-//     along with TestON.  If not, see <http://www.gnu.org/licenses/>.
-
-// This is the dependency Jenkins script.
-// it has some common functions that runs test and generate graph.
-
-import groovy.time.TimeCategory
-import groovy.time.TimeDuration
-
-generalFuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/GeneralFuncs.groovy' )
-fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
-test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
-
-fileRelated.init()
-test_list.init()
-
-nodeLabel = null
-testStation = null
-
-def initializeTrend( machine ){
-    // For initializing any trend graph jobs
-    // machine : Either VM,BM, or Fabric#
-
-    table_name = "executed_test_tests"
-    result_name = "executed_test_results"
-    testStation = "TestStation-" + machine + "s"
-    this.machine = machine
-    isSCPF = false
-    isTrend = true
-}
-
-def initialize( type, testS, nodeL, SCPFfuncs=null ){
-    // initializing for FUNC,HA,SR, and USECASE
-    // type : type of the test ( SR,FUNC,SCPF... )
-
-    testStation = testS
-    testType = type
-    nodeLabel = nodeL
-    isSCPF = ( type == "SCPF" )
-    SCPFfunc = SCPFfuncs
-
-    table_name = "executed_test_tests"
-    result_name = "executed_test_results"
-    trend_generator_file = fileRelated.rScriptPaths[ "scripts" ][ "trendMultiple" ]
-    build_stats_generator_file = fileRelated.rScriptPaths[ "scripts" ][ "histogramMultiple" ]
-    isTrend = false
-}
-
-def getProperties( category, branchWithPrefix ){
-    // get the properties of the test by reading the TestONOS.property
-
-    filePath = '''/var/jenkins/TestONOS-''' + category + '''-''' + branchWithPrefix + '''.property'''
-
-    node( testStation ) {
-        return readProperties( file: filePath )
-    }
-}
-
-def getTestsToRun( testList ){
-    // get test to run by tokenizing the list.
-
-    testList.tokenize( "\n;, " )
-}
-
-def getCurrentTime(){
-    // get time of the PST zone.
-
-    TimeZone.setDefault( TimeZone.getTimeZone( 'PST' ) )
-    return new Date()
-}
-
-def sendResultToSlack( start, isManualRun, branch ){
-    // send the result of the test to the slack when it is not manually running.
-    // start : start time of the test
-    // isManualRun : string that is whether "false" or "true"
-    // branch : branch of the onos.
-
-    try {
-        if ( isManualRun == "false" ){
-            end = getCurrentTime()
-            TimeDuration duration = TimeCategory.minus( end, start )
-            // FIXME: for now we disable notifications of normal test results
-            /*
-            slackSend( color: "#5816EE",
-                       message: testType + "-" + branch + " tests ended at: " + end.toString() +
-                                "\nTime took : " + duration )
-            */
-        }
-    }
-    catch ( all ){
-    }
-}
-
-def initAndRunTest( testName, testCategory ){
-    // Bash script that will
-    // Initialize the environment to the machine and run the test.
-    // testName : name of the test
-    // testCategory : (SR,FUNC ... )
-
-    return '''#!/bin/bash -l
-        set -i # interactive
-        set +e
-        shopt -s expand_aliases # expand alias in non-interactive mode
-        export PYTHONUNBUFFERED=1
-        ifconfig
-        echo "ONOS Branch is: $ONOSBranch"
-        echo "TestON Branch is: $TestONBranch"
-        echo "Test date: "
-        date
-        cd ~
-        export PATH=$PATH:onos/tools/test/bin
-        timeout 240 stc shutdown | head -100
-        timeout 240 stc teardown | head -100
-        timeout 240 stc shutdown | head -100
-        cd ~/OnosSystemTest/TestON/bin
-        git log | head
-        ./cleanup.sh -f
-        ''' + "./cli.py run " +
-          testName +
-           " --params GRAPH/nodeCluster=" + nodeLabel + '''
-        ./cleanup.sh -f
-        # cleanup config changes
-        cd ~/onos/tools/package/config
-        git clean -df'''
-}
-
-def copyLogs(){
-    // bash script to copy the logs and other necessary element for SR tests.
-
-    result = ""
-    if ( testType == "SR" ){
-        result = '''
-      sudo rm /var/jenkins/workspace/SR-log-${WikiPrefix}/*
-      sudo cp *karaf.log.* /var/jenkins/workspace/SR-log-${WikiPrefix}/
-      sudo cp *Flows* /var/jenkins/workspace/SR-log-${WikiPrefix}/
-      sudo cp *Groups* /var/jenkins/workspace/SR-log-${WikiPrefix}/
-      sudo cp *.tar.gz /var/jenkins/workspace/SR-log-${WikiPrefix}/
-      sudo cp t3-* /var/jenkins/workspace/SR-log-${WikiPrefix}/
-      '''
-    }
-    return result
-}
-
-def cleanAndCopyFiles( testName ){
-    // clean up some files that were in the folder and copy the new files from the log
-    // testName : name of the test
-
-    return '''#!/bin/bash -i
-        set +e
-        echo "ONOS Branch is: ${ONOSBranch}"
-        echo "TestON Branch is: ${TestONBranch}"
-        echo "Job name is: "''' + testName + '''
-        echo "Workspace is: ${WORKSPACE}/"
-        echo "Wiki page to post is: ${WikiPrefix}-"
-        # remove any leftover files from previous tests
-        sudo rm ${WORKSPACE}/*Wiki.txt
-        sudo rm ${WORKSPACE}/*Summary.txt
-        sudo rm ${WORKSPACE}/*Result.txt
-        sudo rm ${WORKSPACE}/*Alarm.txt || true
-        sudo rm ${WORKSPACE}/*.csv
-        #copy files to workspace
-        cd `ls -t ~/OnosSystemTest/TestON/logs/*/ | head -1 | sed 's/://'`
-        ''' + copyLogs() + '''
-        sudo cp *.txt ${WORKSPACE}/
-        sudo cp *.csv ${WORKSPACE}/
-        cd ${WORKSPACE}/
-        for i in *.csv
-            do mv "$i" "$WikiPrefix"-"$i"
-        done
-        ls -al
-        cd '''
-}
-
-def fetchLogs( testName ){
-    // fetch the logs of onos from onos nodes to onos System Test logs
-    // testName: name of the test
-
-    return '''#!/bin/bash
-  set +e
-  cd ~/OnosSystemTest/TestON/logs
-  echo "TestON test name is: "''' + testName + '''
-  TestONlogDir=$(ls -t | grep ${TEST_NAME}_  |head -1)
-  echo "########################################################################################"
-  echo "#####  copying ONOS logs from all nodes to TestON/logs directory: ${TestONlogDir}"
-  echo "########################################################################################"
-  cd $TestONlogDir
-  if [ $? -eq 1 ]
-  then
-      echo "Job name does not match any test suite name to move log!"
-  else
-      pwd
-      for i in $OC{1..7}; do onos-fetch-logs $i || echo log does not exist for onos $i; done
-      for i in $OC{1..7}; do atomix-fetch-logs $i || echo log does not exist for atomix $i; done
-  fi
-  cd'''
-}
-
-def isPostingResult( manual, postresult ){
-    // check if it is posting the result.
-    // posting when it is automatically running or has postResult condition from the manual run
-
-    return manual == "false" || postresult == "true"
-}
-
-def postResult( prop, graphOnly ){
-    // post the result by triggering postjob.
-    // prop : property dictionary that was read from the machine.
-    // graphOnly : if it is graph generating job
-
-    if ( graphOnly || isPostingResult( prop[ "manualRun" ], prop[ "postResult" ] ) ){
-        postjob_type = ""
-        switch ( nodeLabel ){
-            case "Fabric-1.x":
-                postjob_type = "Fabric2"
-                break
-            case "Fabric-2.x":
-                postjob_type = "Fabric3"
-                break
-            case "Fabric-master":
-                postjob_type = "Fabric4"
-                break
-            default:
-                postjob_type = nodeLabel
-                break
-        }
-
-        def post = build job: "postjob-" + postjob_type, propagate: false
-    }
-}
-
-def postLogs( testName, prefix ){
-    // posting logs of the onos jobs specifically SR tests
-    // testName : name of the test
-    // prefix : branch prefix ( master, 2.1, 1.15 ... )
-
-    resultURL = ""
-    if ( testType == "SR" ){
-        def post = build job: "SR-log-" + prefix, propagate: false
-        resultURL = post.getAbsoluteUrl()
-    }
-    return resultURL
-}
-
-def getSlackChannel(){
-    // get name of the slack channel.
-    // if the test is SR, it will return sr-failures
-
-    // FIXME: For now we move all notifications to #jenkins-related
-    // return "#" + ( testType == "SR" ? "sr-failures" : "jenkins-related" )
-    return "#jenkins-related"
-}
-
-def analyzeResult( prop, workSpace, pureTestName, testName, resultURL, wikiLink, isSCPF ){
-    // analyzing the result of the test and send to slack if any abnormal result is logged.
-    // prop : property dictionary
-    // workSpace : workSpace where the result file is saved
-    // pureTestName : TestON name of the test
-    // testName : Jenkins name of the test. Example: SCPFflowTPFobj
-    // resultURL : url for the logs for SR tests. Will not be posted if it is empty
-    // wikiLink : link of the wiki page where the result was posted
-    // isSCPF : Check if it is SCPF. If so, it won't post the wiki link.
-
-    node( testStation ) {
-        def alarmFile = workSpace + "/" + pureTestName + "Alarm.txt"
-        if ( fileExists( alarmFile ) ) {
-            def alarmContents = readFile( alarmFile )
-            slackSend( channel: getSlackChannel(),
-                       color: "FF0000",
-                       message: "[" + prop[ "ONOSBranch" ] + "]" + testName + " : triggered alarms:\n" +
-                                alarmContents + "\n" +
-                                "[TestON log] : \n" +
-                                "https://jenkins.onosproject.org/blue/organizations/jenkins/${ env.JOB_NAME }/detail/${ env.JOB_NAME }/${ env.BUILD_NUMBER }/pipeline" +
-                                ( isSCPF ? "" : ( "\n[Result on Wiki] : \n" +
-                                                  "https://wiki.onosproject.org/display/ONOS/" +
-                                                  wikiLink.replaceAll( "\\s", "+" ) ) ) +
-                                ( resultURL != "" ? ( "\n[Karaf log] : \n" +
-                                                      resultURL + "artifact/" ) : "" ),
-                       teamDomain: 'onosproject' )
-            throw new Exception( "Abnormal test result." )
-        }
-        else {
-            print "Test results are OK."
-        }
-    }
-}
-
-def publishToConfluence( isManualRun, isPostResult, wikiLink, file ){
-    // publish HTML script to wiki confluence
-    // isManualRun : string "true" "false"
-    // isPostResult : string "true" "false"
-    // wikiLink : link of the wiki page to publish
-    // file : name of the file to be published
-
-    if ( isPostingResult( isManualRun, isPostResult ) ){
-        publishConfluence siteName: 'wiki.onosproject.org', pageName: wikiLink, spaceName: 'ONOS',
-                          attachArchivedArtifacts: true, buildIfUnstable: true,
-                          editorList: [ confluenceWritePage( confluenceFile( file ) ) ]
-    }
-
-}
-
-def runTest( testName, toBeRun, prop, pureTestName, graphOnly, testCategory, graph_generator_file,
-             graph_saved_directory ){
-    // run the test on the machine that contains all the steps : init and run test, copy files, publish result ...
-    // testName : name of the test in Jenkins
-    // toBeRun : boolean value whether the test will be run or not. If not, it won't be run but shows up with empty
-    //           result on pipeline view
-    // prop : dictionary property on the machine
-    // pureTestName : Pure name of the test. ( ex. pureTestName of SCPFflowTpFobj will be SCPFflowTp )
-    // graphOnly : check if it is generating graph job. If so, it will only generate the generating graph part
-    // testCategory : Map for the test suit ( SCPF, SR, FUNC, ... ) which contains information about the tests
-    // graph_generator_file : Rscript file with the full path.
-    // graph_saved_directory : where the generated graph will be saved to.
-
-    return {
-        catchError {
-            stage( testName ) {
-                if ( toBeRun ){
-                    def workSpace = "/var/jenkins/workspace/" + testName
-                    def fileContents = ""
-                    node( testStation ) {
-                        withEnv( [ 'ONOSBranch=' + prop[ "ONOSBranch" ],
-                                   'ONOSJAVAOPTS=' + prop[ "ONOSJAVAOPTS" ],
-                                   'TestONBranch=' + prop[ "TestONBranch" ],
-                                   'ONOSTag=' + prop[ "ONOSTag" ],
-                                   'WikiPrefix=' + prop[ "WikiPrefix" ],
-                                   'WORKSPACE=' + workSpace ] ) {
-                            if ( !graphOnly ){
-                                if ( isSCPF ){
-                                    // Remove the old database file
-                                    sh SCPFfunc.cleanupDatabaseFile( testName )
-                                }
-                                sh initAndRunTest( testName, testCategory )
-                                // For the Wiki page
-                                sh cleanAndCopyFiles( pureTestName )
-                            }
-                            databaseAndGraph( prop, testName, pureTestName, graphOnly,
-                                              graph_generator_file, graph_saved_directory )
-                            if ( !graphOnly ){
-                                sh fetchLogs( pureTestName )
-                                if ( !isSCPF ){
-                                    publishToConfluence( prop[ "manualRun" ], prop[ "postResult" ],
-                                                         prop[ "WikiPrefix" ] + "-" + testCategory[ testName ][ 'wikiName' ],
-                                                         workSpace + "/" + testCategory[ testName ][ 'wikiFile' ] )
-                                }
-                            }
-                        }
-                    }
-                    postResult( prop, graphOnly )
-                    if ( !graphOnly ){
-                        def resultURL = postLogs( testName, prop[ "WikiPrefix" ] )
-                        analyzeResult( prop, workSpace, pureTestName, testName, resultURL,
-                                       isSCPF ? "" : testCategory[ testName ][ 'wikiName' ],
-                                       isSCPF )
-                    }
-                }
-            }
-        }
-    }
-}
-
-def databaseAndGraph( prop, testName, pureTestName, graphOnly, graph_generator_file, graph_saved_directory ){
-    // part where it insert the data into the database.
-    // It will use the predefined encrypted variables from the Jenkins.
-    // prop : property dictionary that was read from the machine
-    // testName : Jenkins name for the test
-    // pureTestName : TestON name for the test
-    // graphOnly : boolean whether it is graph only or not
-    // graph_generator_file : Rscript file with the full path.
-    // graph_saved_directory : where the generated graph will be saved to.
-    if ( graphOnly || isPostingResult( prop[ "manualRun" ], prop[ "postResult" ] ) ){
-        // Post Results
-        withCredentials( [
-                string( credentialsId: 'db_pass', variable: 'pass' ),
-                string( credentialsId: 'db_user', variable: 'user' ),
-                string( credentialsId: 'db_host', variable: 'host' ),
-                string( credentialsId: 'db_port', variable: 'port' ) ] ) {
-            def database_command = generalFuncs.database_command_create( pass, host, port, user ) +
-                                   ( !isSCPF ? sqlCommand( testName ) : SCPFfunc.sqlCommand( testName ) )
-            sh '''#!/bin/bash
-              export DATE=\$(date +%F_%T)
-              cd ~
-              pwd ''' + ( graphOnly ? "" :
-                          ( !isSCPF ? databasePart( prop[ "WikiPrefix" ], pureTestName, database_command ) :
-                            SCPFfunc.databasePart( testName, database_command ) ) ) + '''
-              ''' + ( !isSCPF ? graphGenerating( host, port, user, pass, testName, prop, graph_saved_directory,
-                                                 graph_generator_file ) :
-                      SCPFfunc.getGraphGeneratingCommand( host, port, user, pass, testName, prop ) )
-        }
-    }
-}
-
-def generateCategoryStatsGraph( testMachineOn, manualRun, postresult, stat_file, pie_file, type, branch, testListPart,
-                                save_path, pieTestListPart ){
-    // function that will generate the category stat graphs for the overall test.
-    // testMachineOn : the machine the graph will be generated. It will be TestStation-VMs for the most cases
-    // manualRun : string of "true" or "false"
-    // postresult : string of "true" or "false"
-    // stat_file : file name with full path for Rscript for the stat graph
-    // pie_file : file name with full path for Rscript for the pie graph
-    // type : type of the test ( USECASE, FUNC, HA )
-    // branch : branch of the test ( master, onos-2.1, onos-1.15 )
-    // testListPart : list of the test to be included
-    // save_path : path that will save the graphs to
-    // pieTestListPart : list of the test for pie graph
-
-    if ( isPostingResult( manualRun, postresult ) ){
-        node( testMachineOn ) {
-
-            withCredentials( [
-                    string( credentialsId: 'db_pass', variable: 'pass' ),
-                    string( credentialsId: 'db_user', variable: 'user' ),
-                    string( credentialsId: 'db_host', variable: 'host' ),
-                    string( credentialsId: 'db_port', variable: 'port' ) ] ) {
-                sh '''#!/bin/bash
-              ''' + generalFuncs.basicGraphPart( stat_file, host, port, user, pass, type,
-                                                 branch ) + " \"" + testListPart + "\" latest " + save_path + '''
-              ''' + getOverallPieGraph( pie_file, host, port, user, pass, branch, type, pieTestListPart, 'y',
-                                        save_path ) + '''
-              ''' +
-                   getOverallPieGraph( pie_file, host, port, user, pass, branch, type, pieTestListPart, 'n', save_path )
-            }
-        }
-        postResult( [ ], true )
-    }
-}
-
-
-def generateOverallGraph( prop, tests, graph_saved_directory ){
-    // generate the overall graph for the test
-
-    if ( isPostingResult( prop[ "manualRun" ], prop[ "postResult" ] ) ){
-        node( testStation ) {
-
-            withCredentials( [
-                    string( credentialsId: 'db_pass', variable: 'pass' ),
-                    string( credentialsId: 'db_user', variable: 'user' ),
-                    string( credentialsId: 'db_host', variable: 'host' ),
-                    string( credentialsId: 'db_port', variable: 'port' ) ] ) {
-                testList = test_list.getTestListAsString( tests )
-                sh '''#!/bin/bash
-                   ''' +
-                   generalFuncs.basicGraphPart( trend_generator_file, host, port,
-                                                user, pass, testType,
-                                                prop[ "ONOSBranch" ] ) + " " + testList + " 20 " + graph_saved_directory
-            }
-        }
-        postResult( prop, false )
-    }
-}
-
-def getOverallPieGraph( file, host, port, user, pass, branch, type, testList, yOrN, path ){
-    // Rcommand for the pie graph
-
-    return generalFuncs.basicGraphPart( file, host, port, user, pass, type, branch ) +
-           " \"" + testList + "\" latest " + yOrN + " " + path
-}
-
-def sqlCommand( testName ){
-    // get the inserting sqlCommand for non-SCPF tests.
-
-    return "\"INSERT INTO " + table_name + " VALUES('\$DATE','" + result_name + "','" +
-           testName + "',\$BUILD_NUMBER, '\$ONOSBranch', \$line);\" "
-}
-
-def graphGenerating( host, port, user, pass, testName, prop, graph_saved_directory, graph_generator_file ){
-    // get the graphGenerating R command for non-SCPF tests
-
-    return generalFuncs.basicGraphPart( graph_generator_file, host, port, user, pass, testName,
-                                        prop[ "ONOSBranch" ] ) + " 20 " + graph_saved_directory
-}
-
-def databasePart( wikiPrefix, testName, database_command ){
-    // to read and insert the data from .csv to the database
-
-    return '''
-    sed 1d ''' + workSpace + "/" + wikiPrefix + "-" + testName + '''.csv | while read line
-    do
-    echo \$line
-    echo ''' + database_command + '''
-    done '''
-}
-
-def generateStatGraph( testMachineOn, onos_branch, stat_graph_generator_file, pie_graph_generator_file,
-                       graph_saved_directory ){
-
-    // Will generate the stats graph.
-    FUNCtestsStr = test_list.getTestListAsString( test_list.getTestsFromCategory( "FUNC" ) )
-    HAtestsStr = test_list.getTestListAsString( test_list.getTestsFromCategory( "HA" ) )
-    USECASEtestsStr = test_list.getTestListAsString( test_list.getTestsFromCategory( "USECASE" ) )
-
-    testListParam = "FUNC-"     + FUNCtestsStr + ";" +
-                    "HA-"       + HAtestsStr   + ";" +
-                    "USECASE-"  + USECASEtestsStr
-
-    pieTestListParam = FUNCtestsStr + "," +
-                       HAtestsStr   + "," +
-                       USECASEtestsStr
-
-    generateCategoryStatsGraph( testMachineOn, "false", "true", stat_graph_generator_file, pie_graph_generator_file,
-                                "ALL", onos_branch, testListParam, graph_saved_directory, pieTestListParam )
-}
-
-return this
diff --git a/TestON/JenkinsFile/dependencies/JenkinsGraphs.groovy b/TestON/JenkinsFile/dependencies/JenkinsGraphs.groovy
new file mode 100644
index 0000000..3aef5a9
--- /dev/null
+++ b/TestON/JenkinsFile/dependencies/JenkinsGraphs.groovy
@@ -0,0 +1,228 @@
+#!groovy
+// Copyright 2017 Open Networking Foundation (ONF)
+//
+// Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
+// the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
+// or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
+//
+//     TestON is free software: you can redistribute it and/or modify
+//     it under the terms of the GNU General Public License as published by
+//     the Free Software Foundation, either version 2 of the License, or
+//     (at your option) any later version.
+//
+//     TestON is distributed in the hope that it will be useful,
+//     but WITHOUT ANY WARRANTY; without even the implied warranty of
+//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//     GNU General Public License for more details.
+//
+//     You should have received a copy of the GNU General Public License
+//     along with TestON.  If not, see <http://www.gnu.org/licenses/>.
+
+// This is the dependency Jenkins script.
+// it has some common functions that runs test and generate graph.
+
+generalFuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/GeneralFuncs.groovy' )
+fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
+test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
+
+fileRelated.init()
+test_list.init()
+
+testStation = null
+isSCPF = null
+
+def initialize( SCPFf=null ){
+    isSCPF = ( SCPFf != null )
+    SCPFfunc = SCPFf
+    trend_generator_file = fileRelated.rScriptPaths[ "scripts" ][ "trendMultiple" ]
+    build_stats_generator_file = fileRelated.rScriptPaths[ "scripts" ][ "histogramMultiple" ]
+}
+
+def postResult( prop, graphOnly, nodeLabel ){
+    // post the result by triggering postjob.
+    // prop : property dictionary that was read from the machine.
+    // graphOnly : if it is graph generating job
+
+    if ( graphOnly || isPostingResult( prop[ "manualRun" ], prop[ "postResult" ] ) ){
+        postjob_type = ""
+        switch ( nodeLabel ){
+            case "Fabric-1.x":
+                postjob_type = "Fabric2"
+                break
+            case "Fabric-2.x":
+                postjob_type = "Fabric3"
+                break
+            case "Fabric-master":
+                postjob_type = "Fabric4"
+                break
+            default:
+                postjob_type = nodeLabel
+                break
+        }
+
+        def post = build job: "postjob-" + postjob_type, propagate: false
+    }
+}
+
+def isPostingResult( manual, postresult ){
+    // check if it is posting the result.
+    // posting when it is automatically running or has postResult condition from the manual run
+
+    return manual == "false" || postresult == "true"
+}
+
+def database_command_create( pass, host, port, user ){
+    return pass + "|psql --host=" + host + " --port=" + port + " --username=" + user + " --password --dbname onostest -c "
+}
+
+def databaseAndGraph( prop, testName, pureTestName, graphOnly, graph_generator_file, graph_saved_directory ){
+    // part where it insert the data into the database.
+    // It will use the predefined encrypted variables from the Jenkins.
+    // prop : property dictionary that was read from the machine
+    // testName : Jenkins name for the test
+    // pureTestName : TestON name for the test
+    // graphOnly : boolean whether it is graph only or not
+    // graph_generator_file : Rscript file with the full path.
+    // graph_saved_directory : where the generated graph will be saved to.
+    if ( graphOnly || isPostingResult( prop[ "manualRun" ], prop[ "postResult" ] ) ){
+        // Post Results
+        withCredentials( [
+                string( credentialsId: 'db_pass', variable: 'pass' ),
+                string( credentialsId: 'db_user', variable: 'user' ),
+                string( credentialsId: 'db_host', variable: 'host' ),
+                string( credentialsId: 'db_port', variable: 'port' ) ] ) {
+            def database_command = database_command_create( pass, host, port, user ) +
+                                   ( !isSCPF ? sqlCommand( testName ) : SCPFfunc.sqlCommand( testName ) )
+            sh script: '''#!/bin/bash
+              export DATE=\$(date +%F_%T)
+              cd ~
+              pwd ''' + ( graphOnly ? "" :
+                          ( !isSCPF ? databasePart( prop[ "WikiPrefix" ], pureTestName, database_command ) :
+                            SCPFfunc.databasePart( testName, database_command ) ) ), label: "Database"
+            sh script: ( !isSCPF ? graphGenerating( host, port, user, pass, testName, prop, graph_saved_directory,
+                                                 graph_generator_file ) :
+                      SCPFfunc.getGraphGeneratingCommand( host, port, user, pass, testName, prop ) ), label: "Generate Test Graph"
+        }
+    }
+}
+
+// make the basic graph part for the Rscript
+def basicGraphPart( rFileName, host, port, user, pass, subject, branchName ){
+    return " Rscript " + rFileName + " " + host + " " + port + " " + user + " " + pass + " " + subject + " " + branchName
+}
+
+def generateCategoryStatsGraph( testMachineOn, manualRun, postresult, stat_file, pie_file, type, branch, testListPart,
+                                save_path, pieTestListPart, nodeLabel ){
+    // function that will generate the category stat graphs for the overall test.
+    // testMachineOn : the machine the graph will be generated. It will be TestStation-VMs for the most cases
+    // manualRun : string of "true" or "false"
+    // postresult : string of "true" or "false"
+    // stat_file : file name with full path for Rscript for the stat graph
+    // pie_file : file name with full path for Rscript for the pie graph
+    // type : type of the test ( USECASE, FUNC, HA )
+    // branch : branch of the test ( master, onos-2.1, onos-1.15 )
+    // testListPart : list of the test to be included
+    // save_path : path that will save the graphs to
+    // pieTestListPart : list of the test for pie graph
+
+    if ( isPostingResult( manualRun, postresult ) ){
+        node( testMachineOn ) {
+
+            withCredentials( [
+                    string( credentialsId: 'db_pass', variable: 'pass' ),
+                    string( credentialsId: 'db_user', variable: 'user' ),
+                    string( credentialsId: 'db_host', variable: 'host' ),
+                    string( credentialsId: 'db_port', variable: 'port' ) ] ) {
+                sh script: ( '''#!/bin/bash
+              ''' + basicGraphPart( stat_file, host, port, user, pass, type,
+                                                 branch ) + " \"" + testListPart + "\" latest " + save_path + '''
+              ''' + getOverallPieGraph( pie_file, host, port, user, pass, branch, type, pieTestListPart, 'y',
+                                        save_path ) + '''
+              ''' + getOverallPieGraph( pie_file, host, port, user, pass, branch, type, pieTestListPart, 'n', save_path ) ), label: "Generate Stats Graphs"
+            }
+        }
+        postResult( [ ], true, nodeLabel )
+    }
+}
+
+
+def generateOverallGraph( prop, tests, graph_saved_directory, nodeLabel, testType ){
+    // generate the overall graph for the test
+
+    if ( isPostingResult( prop[ "manualRun" ], prop[ "postResult" ] ) ){
+        node( testStation ) {
+
+            withCredentials( [
+                    string( credentialsId: 'db_pass', variable: 'pass' ),
+                    string( credentialsId: 'db_user', variable: 'user' ),
+                    string( credentialsId: 'db_host', variable: 'host' ),
+                    string( credentialsId: 'db_port', variable: 'port' ) ] ) {
+                testList = test_list.getTestListAsString( tests )
+                sh script: ( '''#!/bin/bash''' +
+                   basicGraphPart( trend_generator_file, host, port,
+                                                user, pass, testType,
+                                                prop[ "ONOSBranch" ] ) + " " + testList + " 20 " + graph_saved_directory ), label: "Generate Overall Graph"
+            }
+        }
+        postResult( prop, false, nodeLabel )
+    }
+}
+
+def getOverallPieGraph( file, host, port, user, pass, branch, type, testList, yOrN, path ){
+    // Rcommand for the pie graph
+
+    return basicGraphPart( file, host, port, user, pass, type, branch ) +
+           " \"" + testList + "\" latest " + yOrN + " " + path
+}
+
+def sqlCommand( testName ){
+    // get the inserting sqlCommand for non-SCPF tests.
+    table_name = "executed_test_tests"
+    result_name = "executed_test_results"
+
+    return "\"INSERT INTO " + table_name + " VALUES('\$DATE','" + result_name + "','" +
+           testName + "',\$BUILD_NUMBER, '\$ONOSBranch', \$line);\" "
+}
+
+def graphGenerating( host, port, user, pass, testName, prop, graph_saved_directory, graph_generator_file ){
+    // get the graphGenerating R command for non-SCPF tests
+
+    return basicGraphPart( graph_generator_file, host, port, user, pass, testName,
+                                        prop[ "ONOSBranch" ] ) + " 20 " + graph_saved_directory
+}
+
+def databasePart( wikiPrefix, testName, database_command ){
+    // to read and insert the data from .csv to the database
+
+    return '''
+    sed 1d ''' + workSpace + "/" + wikiPrefix + "-" + testName + '''.csv | while read line
+    do
+    echo \$line
+    echo ''' + database_command + '''
+    done '''
+}
+
+def generateStatGraph( testMachineOn, onos_branch, stat_graph_generator_file, pie_graph_generator_file,
+                       graph_saved_directory, nodeLabel ){
+
+    table_name = "executed_test_tests"
+    result_name = "executed_test_results"
+
+    // Will generate the stats graph.
+    FUNCtestsStr = test_list.getTestListAsString( test_list.getTestsFromCategory( "FUNC" ) )
+    HAtestsStr = test_list.getTestListAsString( test_list.getTestsFromCategory( "HA" ) )
+    USECASEtestsStr = test_list.getTestListAsString( test_list.getTestsFromCategory( "USECASE" ) )
+
+    testListParam = "FUNC-"     + FUNCtestsStr + ";" +
+                    "HA-"       + HAtestsStr   + ";" +
+                    "USECASE-"  + USECASEtestsStr
+
+    pieTestListParam = FUNCtestsStr + "," +
+                       HAtestsStr   + "," +
+                       USECASEtestsStr
+
+    generateCategoryStatsGraph( testMachineOn, "false", "true", stat_graph_generator_file, pie_graph_generator_file,
+                                "ALL", onos_branch, testListParam, graph_saved_directory, pieTestListParam, nodeLabel )
+}
+
+return this
diff --git a/TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy b/TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy
index 452ddfc..fd70fcc 100644
--- a/TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy
+++ b/TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy
@@ -255,10 +255,15 @@
     return result
 }
 
+// make the basic graph part for the Rscript
+def basicGraphPart( rFileName, host, port, user, pass, subject, branchName ){
+    return " Rscript " + rFileName + " " + host + " " + port + " " + user + " " + pass + " " + subject + " " + branchName
+}
+
 def generateGraph( rFileName, batch, host, port, user, pass, testName, branchName, isOldFlow ){
     //  generate the Rscript command for individual graphs
 
-    return generalFuncs.basicGraphPart( fileRelated.rScriptPaths[ "directories" ][ "SCPF" ] + rFileName,
+    return basicGraphPart( fileRelated.rScriptPaths[ "directories" ][ "SCPF" ] + rFileName,
                                         host, port, user, pass, testName, branchName ) +
            " " + batch + " " + usingOldFlow( isOldFlow, testName ) + graph_saved_directory
 }
@@ -268,7 +273,7 @@
     def result = ""
 
     for ( int i = 0; i < SCPF[ testName ][ 'graphTitle' ].size(); i++ ){
-        result += generalFuncs.basicGraphPart( fileRelated.rScriptPaths[ "scripts" ][ "trendSCPF" ],
+        result += basicGraphPart( fileRelated.rScriptPaths[ "scripts" ][ "trendSCPF" ],
                                                host,
                                                port,
                                                user,
diff --git a/TestON/JenkinsFile/dependencies/TriggerFuncs.groovy b/TestON/JenkinsFile/dependencies/TriggerFuncs.groovy
deleted file mode 100644
index b6b3212..0000000
--- a/TestON/JenkinsFile/dependencies/TriggerFuncs.groovy
+++ /dev/null
@@ -1,238 +0,0 @@
-#!groovy
-
-// Copyright 2017 Open Networking Foundation (ONF)
-//
-// Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
-// the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
-// or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
-//
-//     TestON is free software: you can redistribute it and/or modify
-//     it under the terms of the GNU General Public License as published by
-//     the Free Software Foundation, either version 2 of the License, or
-//     (at your option) any later version.
-//
-//     TestON is distributed in the hope that it will be useful,
-//     but WITHOUT ANY WARRANTY; without even the implied warranty of
-//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//     GNU General Public License for more details.
-//
-//     You should have received a copy of the GNU General Public License
-//     along with TestON.  If not, see <http://www.gnu.org/licenses/>.
-
-// This is the dependency Jenkins script.
-// This will provide the portion that will set up the environment of the machine
-//      and trigger the corresponding jobs.
-
-import groovy.time.TimeCategory
-import groovy.time.TimeDuration
-
-test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
-test_list.init()
-
-def printDaysForTest(){
-    // Print the days for what test has.
-    AllTheTests = test_list.getAllTests()
-
-    result = ""
-    for ( String test in AllTheTests.keySet() ){
-        result += test + ": ["
-        test_schedule = AllTheTests[ test ][ "schedules" ]
-        for ( String sch_dict in test_schedule ){
-            for ( String day in test_list.convertScheduleKeyToDays( sch_dict[ "branch" ] ) ){
-                result += day + " "
-            }
-        }
-        result += "]\n"
-    }
-    return result
-}
-
-def trigger( branch, tests, nodeLabel, jobOn, manuallyRun, onosTag ){
-    // triggering function that will setup the environment and determine which pipeline to trigger
-
-    println "Job name: " + jobOn + "-pipeline-" + ( manuallyRun ? "manually" : branch )
-    def wiki = branch
-    def onos_branch = test_list.addPrefixToBranch( branch )
-    def test_branch = test_list.addPrefixToBranch( branch )
-    println "onos_branch with prefix: " + onos_branch
-    println "test_branch with prefix: " + test_branch
-    assignedNode = null
-    node( label: nodeLabel ) {
-        envSetup( onos_branch, test_branch, onosTag, jobOn, manuallyRun )
-        exportEnvProperty( onos_branch, test_branch, jobOn, wiki, tests, post_result, manuallyRun, onosTag, isOldFlow, nodeLabel )
-        assignedNode = env.NODE_NAME
-    }
-
-    jobToRun = jobOn + "-pipeline-" + ( manuallyRun ? "manually" : wiki )
-    build job: jobToRun, propagate: false, parameters: [ [ $class: 'StringParameterValue', name: 'Category', value: jobOn ],
-                                                         [ $class: 'StringParameterValue', name: 'Branch', value: branch ],
-                                                         [ $class: 'StringParameterValue', name: 'TestStation', value: assignedNode ],
-                                                         [ $class: 'StringParameterValue', name: 'NodeLabel', value: nodeLabel ] ]
-}
-
-def trigger_pipeline( branch, tests, nodeLabel, jobOn, manuallyRun, onosTag ){
-    // nodeLabel : nodeLabel from tests.json
-    // jobOn : "SCPF" or "USECASE" or "FUNC" or "HA"
-    // this will return the function by wrapping them up with return{} to prevent them to be
-    // executed once this function is called to assign to specific variable.
-    return {
-        trigger( branch, tests, nodeLabel, jobOn, manuallyRun, onosTag )
-    }
-}
-
-// export Environment properties.
-def exportEnvProperty( onos_branch, test_branch, jobOn, wiki, tests, postResult, manually_run, onosTag, isOldFlow, nodeLabel ){
-    // export environment properties to the machine.
-
-    filePath = "/var/jenkins/TestONOS-" + jobOn + "-" + onos_branch + ".property"
-
-    stage( "export Property" ) {
-        sh '''
-            echo "ONOSBranch=''' + onos_branch + '''" > ''' + filePath + '''
-            echo "TestONBranch=''' + test_branch + '''" >> ''' + filePath + '''
-            echo "ONOSTag=''' + onosTag + '''" >> ''' + filePath + '''
-            echo "WikiPrefix=''' + wiki + '''" >> ''' + filePath + '''
-            echo "ONOSJAVAOPTS=''' + env.ONOSJAVAOPTS + '''" >> ''' + filePath + '''
-            echo "Tests=''' + tests + '''" >> ''' + filePath + '''
-            echo "postResult=''' + postResult + '''" >> ''' + filePath + '''
-            echo "manualRun=''' + manually_run + '''" >> ''' + filePath + '''
-            echo "isOldFlow=''' + isOldFlow + '''" >> ''' + filePath + '''
-        '''
-    }
-}
-
-// Initialize the environment Setup for the onos and OnosSystemTest
-def envSetup( onos_branch, test_branch, onos_tag, jobOn, manuallyRun ){
-    // to setup the environment using the bash script
-    println "onos_branch is set to " + onos_branch
-    println "test_branch is set to " + test_branch
-    stage( "envSetup" ) {
-        // after env: ''' + borrow_mn( jobOn ) + '''
-        sh '''#!/bin/bash -l
-        set +e
-        . ~/.bashrc
-        env
-        ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun ) + '''
-        ''' + oldFlowCheck( jobOn, onos_branch ) + '''
-        ''' + postSetup( onos_branch, test_branch, onos_tag, manuallyRun )
-        generateKey()
-    }
-}
-
-def tagCheck( onos_tag, onos_branch ){
-    // check the tag for onos if it is not empty
-
-    result = "git checkout "
-    if ( onos_tag == "" ){
-        //create new local branch
-        result += onos_branch
-    }
-    else {
-        //checkout the tag
-        result += onos_tag
-    }
-    return result
-}
-
-def preSetup( onos_branch, test_branch, onos_tag, isManual ){
-    // pre setup part which will clean up and checkout to corresponding branch.
-
-    result = ""
-    if ( !isManual ){
-        result = '''echo -e "\n#####  Set TestON Branch #####"
-        echo "TestON Branch is set on: ''' + test_branch + '''"
-        cd ~/OnosSystemTest/
-        git checkout HEAD~1      # Make sure you aren't pn a branch
-        git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
-        git branch -D ''' + test_branch + ''' # just in case there are local changes. This will normally result in a branch not found error
-        git clean -df # clean any local files
-        git fetch --all # update all caches from remotes
-        git reset --hard origin/''' + test_branch + '''  # force local index to match remote branch
-        git clean -df # clean any local files
-        git checkout ''' + test_branch + ''' #create new local branch
-        git branch
-        git log -1 --decorate
-        echo -e "\n#####  Set ONOS Branch #####"
-        echo "ONOS Branch is set on: ''' + onos_branch + '''"
-        echo -e "\n #### check karaf version ######"
-        env |grep karaf
-        cd ~/onos
-        git checkout HEAD~1      # Make sure you aren't pn a branch
-        git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
-        git branch -D ''' + onos_branch + ''' # just incase there are local changes. This will normally result in a branch not found error
-        git clean -df # clean any local files
-        git fetch --all # update all caches from remotes
-        git reset --hard origin/''' + onos_branch + '''  # force local index to match remote branch
-        git clean -df # clean any local files
-        rm -rf buck-out
-        rm -rf bazel-*
-        ''' + tagCheck( onos_tag, onos_branch ) + '''
-        git branch
-        git log -1 --decorate
-        echo -e "\n##### set jvm heap size to 8G #####"
-        echo ${ONOSJAVAOPTS}
-        inserted_line="export JAVA_OPTS=\"\${ONOSJAVAOPTS}\""
-        sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service
-        echo "##### Check onos-service setting..... #####"
-        cat ~/onos/tools/package/bin/onos-service
-        export JAVA_HOME=/usr/lib/jvm/java-8-oracle'''
-    }
-    return result
-}
-
-def oldFlowCheck( jobOn, onos_branch ){
-    // part that will check if it is oldFlow. If so, it will switch to use old flow. Only affected with SCPF.
-
-    result = ""
-    if ( jobOn == "SCPF" && ( onos_branch == "master" || onos_branch == "onos-1.12" ) )
-        result = '''sed -i -e 's/@Component(immediate = true)/@Component(enabled = false)/g' ~/onos/core/store/dist/src/main/java/org/onosproject/store/flow/impl/''' + ( isOldFlow ? "DistributedFlowRuleStore" : "ECFlowRuleStore" ) + '''.java
-        sed -i -e 's/@Component(enabled = false)/@Component(immediate = true)/g' ~/onos/core/store/dist/src/main/java/org/onosproject/store/flow/impl/''' + ( isOldFlow ? "ECFlowRuleStore" : "DistributedFlowRuleStore" ) + ".java"
-    return result
-}
-
-def postSetup( onos_branch, test_branch, onos_tag, isManual ){
-    // setup that will build ONOS
-
-    result = ""
-    if ( !isManual ){
-        result = '''echo -e "Installing bazel"
-        cd ~
-        rm -rf ci-management
-        git clone https://gerrit.onosproject.org/ci-management
-        cd ci-management/jjb/onos/
-        export GERRIT_BRANCH="''' + onos_branch + '''"
-        chmod +x install-bazel.sh
-        ./install-bazel.sh
-        bazel --version
-
-        echo -e "\n##### build ONOS skip unit tests ######"
-        cd ~/onos
-        . tools/dev/bash_profile
-        op
-        sleep 30
-        echo -e "\n##### Stop all running instances of Karaf #####"
-        kill $(ps -efw | grep karaf | grep -v grep | awk '{print $2}')
-        sleep 30
-        git branch
-        '''
-    }
-    return result
-}
-
-def generateKey(){
-    // generate cluster-key of the onos
-
-    try {
-        sh '''
-        #!/bin/bash -l
-        set +e
-        . ~/.bashrc
-        env
-        onos-push-bits-through-proxy
-        onos-gen-cluster-key -f
-        '''
-    } catch ( all ){
-    }
-}
-
-return this
