blob: 424f9a3710995c424eff77074aa451668f9c6647 [file] [log] [blame]
Devin Lim64a2eca2018-05-10 18:44:52 -07001#!groovy
Devin Limb734ea52018-05-14 14:13:05 -07002fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
Devin Lim64a2eca2018-05-10 18:44:52 -07003
Devin Limfe9a4cb2018-05-11 17:06:21 -07004fileRelated.init()
Devin Lim64a2eca2018-05-10 18:44:52 -07005branches = params.ONOSbranch
Devin Lime4e90ee2018-05-14 13:52:54 -07006hours = params.hours
Devin Lim64a2eca2018-05-10 18:44:52 -07007branchList = branches.tokenize( "\n;, " )
Devin Limfe9a4cb2018-05-11 17:06:21 -07008script_file = fileRelated.trendCHO
9saving_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric5/"
10scriptDir = fileRelated.CHOScriptDir
Devin Lim64a2eca2018-05-10 18:44:52 -070011
12graphScript = generateGraphScript( branchList )
13
14stage( 'Generating-Graph' ){
15 node( "TestStation-Fabric5s" ){
16 runScript( graphScript )
17 }
18}
19stage( 'posting-result' ){
20 postJob()
21}
22
23def generateGraphScript( branchList ){
24 graphScript = ''''''
25 for( branch in branchList ){
26 branchDir = scriptDir + branch + "/"
Devin Limd482df72018-05-11 13:52:34 -070027 graphScript += '''export BRANCH=''' + branchDir + '''
28 mkdir ''' + branchDir + ''';
Devin Lim8f7b3bc2018-05-11 14:55:04 -070029 if [ ! -f ''' + branchDir + '''existing.txt ]; then
30 cp *.csv ''' + branchDir + ''';
Devin Lim9e2f3652018-05-11 16:03:41 -070031 echo "1" > ''' + branchDir + '''existing.txt;
Devin Lim8f7b3bc2018-05-11 14:55:04 -070032 fi;
Devin Lim64a2eca2018-05-10 18:44:52 -070033 bash log-summary;''' + '''
Devin Lim324806b2018-05-11 15:36:52 -070034 Rscript ''' + script_file + ' ' + branchDir + 'event.csv ' +
Devin Lim64a2eca2018-05-10 18:44:52 -070035 branchDir + 'failure.csv ' + branchDir + 'error.csv ' +
Devin Lime4e90ee2018-05-14 13:52:54 -070036 branch + ' 60 ' + hours + ' ' + saving_directory + ''';
Devin Lim64a2eca2018-05-10 18:44:52 -070037 '''
38 print( graphScript )
39 }
40 return graphScript
41}
42def runScript( graphScript ){
43 sh '''#!/bin/bash -l
44 set -i
45 set +e
46 export PYTHONPATH=/home/sdn/TestON:/home/sdn/sts
Devin Limd482df72018-05-11 13:52:34 -070047 cd ''' + scriptDir + ''';
48 ''' + graphScript
Devin Lim64a2eca2018-05-10 18:44:52 -070049}
50def postJob(){
51 jobToRun = "postjob-Fabric5"
52 build job: jobToRun, propagate: false
53}