Devin Lim | 64a2eca | 2018-05-10 18:44:52 -0700 | [diff] [blame] | 1 | #!groovy |
| 2 | |
| 3 | branches = params.ONOSbranch |
| 4 | branchList = branches.tokenize( "\n;, " ) |
| 5 | script_file = "TestON/JenkinsFile/wikiGraphRScripts/trendCHO.R" |
| 6 | saving_directory = "/var/jenkins/workspace/postjob-Fabric5/" |
| 7 | scriptDir = "~/CHO_Jenkins_Scripts/" |
| 8 | |
| 9 | graphScript = generateGraphScript( branchList ) |
| 10 | |
| 11 | stage( 'Generating-Graph' ){ |
| 12 | node( "TestStation-Fabric5s" ){ |
| 13 | runScript( graphScript ) |
| 14 | } |
| 15 | } |
| 16 | stage( 'posting-result' ){ |
| 17 | postJob() |
| 18 | } |
| 19 | |
| 20 | def generateGraphScript( branchList ){ |
| 21 | graphScript = '''''' |
| 22 | for( branch in branchList ){ |
| 23 | branchDir = scriptDir + branch + "/" |
Devin Lim | d482df7 | 2018-05-11 13:52:34 -0700 | [diff] [blame] | 24 | graphScript += '''export BRANCH=''' + branchDir + ''' |
| 25 | mkdir ''' + branchDir + '''; |
Devin Lim | 21681b8 | 2018-05-11 14:20:06 -0700 | [diff] [blame] | 26 | cp *.csv ''' + branchDir + '''; |
Devin Lim | 64a2eca | 2018-05-10 18:44:52 -0700 | [diff] [blame] | 27 | bash log-summary;''' + ''' |
| 28 | ''' + script_file + ' ' + branchDir + 'event.csv ' + |
| 29 | branchDir + 'failure.csv ' + branchDir + 'error.csv ' + |
| 30 | branch + ' 60 ' + saving_directory + '''; |
| 31 | ''' |
| 32 | print( graphScript ) |
| 33 | } |
| 34 | return graphScript |
| 35 | } |
| 36 | def runScript( graphScript ){ |
| 37 | sh '''#!/bin/bash -l |
| 38 | set -i |
| 39 | set +e |
| 40 | export PYTHONPATH=/home/sdn/TestON:/home/sdn/sts |
Devin Lim | d482df7 | 2018-05-11 13:52:34 -0700 | [diff] [blame] | 41 | cd ''' + scriptDir + '''; |
| 42 | ''' + graphScript |
Devin Lim | 64a2eca | 2018-05-10 18:44:52 -0700 | [diff] [blame] | 43 | } |
| 44 | def postJob(){ |
| 45 | jobToRun = "postjob-Fabric5" |
| 46 | build job: jobToRun, propagate: false |
| 47 | } |