Devin Lim | 64a2eca | 2018-05-10 18:44:52 -0700 | [diff] [blame] | 1 | #!groovy |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame^] | 2 | fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/JenkinsPathAndFiles.groovy' ) |
Devin Lim | 64a2eca | 2018-05-10 18:44:52 -0700 | [diff] [blame] | 3 | |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame^] | 4 | fileRelated.init() |
Devin Lim | 64a2eca | 2018-05-10 18:44:52 -0700 | [diff] [blame] | 5 | branches = params.ONOSbranch |
| 6 | branchList = branches.tokenize( "\n;, " ) |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame^] | 7 | script_file = fileRelated.trendCHO |
| 8 | saving_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric5/" |
| 9 | scriptDir = fileRelated.CHOScriptDir |
Devin Lim | 64a2eca | 2018-05-10 18:44:52 -0700 | [diff] [blame] | 10 | |
| 11 | graphScript = generateGraphScript( branchList ) |
| 12 | |
| 13 | stage( 'Generating-Graph' ){ |
| 14 | node( "TestStation-Fabric5s" ){ |
| 15 | runScript( graphScript ) |
| 16 | } |
| 17 | } |
| 18 | stage( 'posting-result' ){ |
| 19 | postJob() |
| 20 | } |
| 21 | |
| 22 | def generateGraphScript( branchList ){ |
| 23 | graphScript = '''''' |
| 24 | for( branch in branchList ){ |
| 25 | branchDir = scriptDir + branch + "/" |
Devin Lim | d482df7 | 2018-05-11 13:52:34 -0700 | [diff] [blame] | 26 | graphScript += '''export BRANCH=''' + branchDir + ''' |
| 27 | mkdir ''' + branchDir + '''; |
Devin Lim | 8f7b3bc | 2018-05-11 14:55:04 -0700 | [diff] [blame] | 28 | if [ ! -f ''' + branchDir + '''existing.txt ]; then |
| 29 | cp *.csv ''' + branchDir + '''; |
Devin Lim | 9e2f365 | 2018-05-11 16:03:41 -0700 | [diff] [blame] | 30 | echo "1" > ''' + branchDir + '''existing.txt; |
Devin Lim | 8f7b3bc | 2018-05-11 14:55:04 -0700 | [diff] [blame] | 31 | fi; |
Devin Lim | 64a2eca | 2018-05-10 18:44:52 -0700 | [diff] [blame] | 32 | bash log-summary;''' + ''' |
Devin Lim | 324806b | 2018-05-11 15:36:52 -0700 | [diff] [blame] | 33 | Rscript ''' + script_file + ' ' + branchDir + 'event.csv ' + |
Devin Lim | 64a2eca | 2018-05-10 18:44:52 -0700 | [diff] [blame] | 34 | branchDir + 'failure.csv ' + branchDir + 'error.csv ' + |
| 35 | branch + ' 60 ' + saving_directory + '''; |
| 36 | ''' |
| 37 | print( graphScript ) |
| 38 | } |
| 39 | return graphScript |
| 40 | } |
| 41 | def runScript( graphScript ){ |
| 42 | sh '''#!/bin/bash -l |
| 43 | set -i |
| 44 | set +e |
| 45 | export PYTHONPATH=/home/sdn/TestON:/home/sdn/sts |
Devin Lim | d482df7 | 2018-05-11 13:52:34 -0700 | [diff] [blame] | 46 | cd ''' + scriptDir + '''; |
| 47 | ''' + graphScript |
Devin Lim | 64a2eca | 2018-05-10 18:44:52 -0700 | [diff] [blame] | 48 | } |
| 49 | def postJob(){ |
| 50 | jobToRun = "postjob-Fabric5" |
| 51 | build job: jobToRun, propagate: false |
| 52 | } |