blob: 6e9bc2454f5436c9d7e5c0b90b8462d68bf01e8a [file] [log] [blame]
Devin Lim64a2eca2018-05-10 18:44:52 -07001#!groovy
2
3branches = params.ONOSbranch
4branchList = branches.tokenize( "\n;, " )
Devin Lim85fb2fd2018-05-11 14:58:05 -07005script_file = "~/OnosSystemTest/TestON/JenkinsFile/wikiGraphRScripts/trendCHO.R"
Devin Lim64a2eca2018-05-10 18:44:52 -07006saving_directory = "/var/jenkins/workspace/postjob-Fabric5/"
7scriptDir = "~/CHO_Jenkins_Scripts/"
8
9graphScript = generateGraphScript( branchList )
10
11stage( 'Generating-Graph' ){
12 node( "TestStation-Fabric5s" ){
13 runScript( graphScript )
14 }
15}
16stage( 'posting-result' ){
17 postJob()
18}
19
20def generateGraphScript( branchList ){
21 graphScript = ''''''
22 for( branch in branchList ){
23 branchDir = scriptDir + branch + "/"
Devin Limd482df72018-05-11 13:52:34 -070024 graphScript += '''export BRANCH=''' + branchDir + '''
25 mkdir ''' + branchDir + ''';
Devin Lim8f7b3bc2018-05-11 14:55:04 -070026 if [ ! -f ''' + branchDir + '''existing.txt ]; then
27 cp *.csv ''' + branchDir + ''';
Devin Lim9e2f3652018-05-11 16:03:41 -070028 echo "1" > ''' + branchDir + '''existing.txt;
Devin Lim8f7b3bc2018-05-11 14:55:04 -070029 fi;
Devin Lim64a2eca2018-05-10 18:44:52 -070030 bash log-summary;''' + '''
Devin Lim324806b2018-05-11 15:36:52 -070031 Rscript ''' + script_file + ' ' + branchDir + 'event.csv ' +
Devin Lim64a2eca2018-05-10 18:44:52 -070032 branchDir + 'failure.csv ' + branchDir + 'error.csv ' +
33 branch + ' 60 ' + saving_directory + ''';
34 '''
35 print( graphScript )
36 }
37 return graphScript
38}
39def runScript( graphScript ){
40 sh '''#!/bin/bash -l
41 set -i
42 set +e
43 export PYTHONPATH=/home/sdn/TestON:/home/sdn/sts
Devin Limd482df72018-05-11 13:52:34 -070044 cd ''' + scriptDir + ''';
45 ''' + graphScript
Devin Lim64a2eca2018-05-10 18:44:52 -070046}
47def postJob(){
48 jobToRun = "postjob-Fabric5"
49 build job: jobToRun, propagate: false
50}