blob: 1ed8eb6af02c994e25041eef4d3993fadf0f2c23 [file] [log] [blame]
Devin Lim64a2eca2018-05-10 18:44:52 -07001#!groovy
Devin Limfe9a4cb2018-05-11 17:06:21 -07002fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/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
6branchList = branches.tokenize( "\n;, " )
Devin Limfe9a4cb2018-05-11 17:06:21 -07007script_file = fileRelated.trendCHO
8saving_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric5/"
9scriptDir = fileRelated.CHOScriptDir
Devin Lim64a2eca2018-05-10 18:44:52 -070010
11graphScript = generateGraphScript( branchList )
12
13stage( 'Generating-Graph' ){
14 node( "TestStation-Fabric5s" ){
15 runScript( graphScript )
16 }
17}
18stage( 'posting-result' ){
19 postJob()
20}
21
22def generateGraphScript( branchList ){
23 graphScript = ''''''
24 for( branch in branchList ){
25 branchDir = scriptDir + branch + "/"
Devin Limd482df72018-05-11 13:52:34 -070026 graphScript += '''export BRANCH=''' + branchDir + '''
27 mkdir ''' + branchDir + ''';
Devin Lim8f7b3bc2018-05-11 14:55:04 -070028 if [ ! -f ''' + branchDir + '''existing.txt ]; then
29 cp *.csv ''' + branchDir + ''';
Devin Lim9e2f3652018-05-11 16:03:41 -070030 echo "1" > ''' + branchDir + '''existing.txt;
Devin Lim8f7b3bc2018-05-11 14:55:04 -070031 fi;
Devin Lim64a2eca2018-05-10 18:44:52 -070032 bash log-summary;''' + '''
Devin Lim324806b2018-05-11 15:36:52 -070033 Rscript ''' + script_file + ' ' + branchDir + 'event.csv ' +
Devin Lim64a2eca2018-05-10 18:44:52 -070034 branchDir + 'failure.csv ' + branchDir + 'error.csv ' +
35 branch + ' 60 ' + saving_directory + ''';
36 '''
37 print( graphScript )
38 }
39 return graphScript
40}
41def runScript( graphScript ){
42 sh '''#!/bin/bash -l
43 set -i
44 set +e
45 export PYTHONPATH=/home/sdn/TestON:/home/sdn/sts
Devin Limd482df72018-05-11 13:52:34 -070046 cd ''' + scriptDir + ''';
47 ''' + graphScript
Devin Lim64a2eca2018-05-10 18:44:52 -070048}
49def postJob(){
50 jobToRun = "postjob-Fabric5"
51 build job: jobToRun, propagate: false
52}