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 | 64a2eca | 2018-05-10 18:44:52 -0700 | [diff] [blame] | 26 | bash log-summary;''' + ''' |
| 27 | ''' + script_file + ' ' + branchDir + 'event.csv ' + |
| 28 | branchDir + 'failure.csv ' + branchDir + 'error.csv ' + |
| 29 | branch + ' 60 ' + saving_directory + '''; |
| 30 | ''' |
| 31 | print( graphScript ) |
| 32 | } |
| 33 | return graphScript |
| 34 | } |
| 35 | def runScript( graphScript ){ |
| 36 | sh '''#!/bin/bash -l |
| 37 | set -i |
| 38 | set +e |
| 39 | export PYTHONPATH=/home/sdn/TestON:/home/sdn/sts |
Devin Lim | d482df7 | 2018-05-11 13:52:34 -0700 | [diff] [blame^] | 40 | cd ''' + scriptDir + '''; |
| 41 | ''' + graphScript |
Devin Lim | 64a2eca | 2018-05-10 18:44:52 -0700 | [diff] [blame] | 42 | } |
| 43 | def postJob(){ |
| 44 | jobToRun = "postjob-Fabric5" |
| 45 | build job: jobToRun, propagate: false |
| 46 | } |