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