[ae28ee2] | 1 | #!groovy |
---|
| 2 | |
---|
| 3 | //=========================================================================================================== |
---|
| 4 | // Main loop of the compilation |
---|
| 5 | //=========================================================================================================== |
---|
| 6 | |
---|
| 7 | node ('master') { |
---|
| 8 | def err = null |
---|
| 9 | |
---|
[4af1021] | 10 | final scmVars = checkout scm |
---|
| 11 | final commitId = scmVars.GIT_COMMIT |
---|
[98168b9] | 12 | |
---|
[ae28ee2] | 13 | try { |
---|
[f408e1a] | 14 | //Wrap build to add timestamp to command line |
---|
| 15 | wrap([$class: 'TimestamperBuildWrapper']) { |
---|
| 16 | |
---|
| 17 | stage('Build') { |
---|
| 18 | |
---|
| 19 | parallel ( |
---|
[ef1d025d] | 20 | gcc_8_x86_new: { trigger_build( 'gcc-8', 'x86' ) }, |
---|
| 21 | gcc_7_x86_new: { trigger_build( 'gcc-7', 'x86' ) }, |
---|
| 22 | gcc_6_x86_new: { trigger_build( 'gcc-6', 'x86' ) }, |
---|
| 23 | gcc_9_x64_new: { trigger_build( 'gcc-9', 'x64' ) }, |
---|
| 24 | gcc_8_x64_new: { trigger_build( 'gcc-8', 'x64' ) }, |
---|
| 25 | gcc_7_x64_new: { trigger_build( 'gcc-7', 'x64' ) }, |
---|
| 26 | gcc_6_x64_new: { trigger_build( 'gcc-6', 'x64' ) }, |
---|
| 27 | gcc_5_x64_new: { trigger_build( 'gcc-5', 'x64' ) }, |
---|
| 28 | clang_x64_new: { trigger_build( 'clang', 'x64' ) }, |
---|
[f408e1a] | 29 | ) |
---|
[ae28ee2] | 30 | } |
---|
[8089fde] | 31 | |
---|
| 32 | stage('Package') { |
---|
[b19fdb9] | 33 | trigger_dist( commitId, currentBuild.number.toString() ) |
---|
[8089fde] | 34 | } |
---|
[ae28ee2] | 35 | } |
---|
[13c98a4] | 36 | |
---|
| 37 | promote_email(true) |
---|
[ae28ee2] | 38 | } |
---|
| 39 | |
---|
| 40 | //If an exception is caught we need to change the status and remember to |
---|
| 41 | //attach the build log to the email |
---|
| 42 | catch (Exception caughtError) { |
---|
| 43 | echo('error caught') |
---|
| 44 | |
---|
| 45 | //rethrow error later |
---|
| 46 | err = caughtError |
---|
| 47 | |
---|
| 48 | //Store the result of the build log |
---|
| 49 | currentBuild.result = 'FAILURE' |
---|
| 50 | |
---|
| 51 | //Send email to notify the failure |
---|
[13c98a4] | 52 | promote_email(false) |
---|
[ae28ee2] | 53 | } |
---|
| 54 | |
---|
| 55 | finally { |
---|
| 56 | //Must re-throw exception to propagate error |
---|
| 57 | if (err) { |
---|
| 58 | throw err |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | } |
---|
| 62 | //=========================================================================================================== |
---|
| 63 | // Main compilation routines |
---|
| 64 | //=========================================================================================================== |
---|
| 65 | |
---|
[ef1d025d] | 66 | def trigger_build(String cc, String arch) { |
---|
[9eb7a532] | 67 | // Randomly delay the builds by a random amount to avoid hitting the SC server to hard |
---|
| 68 | sleep(time: 5 * Math.random(), unit:"MINUTES") |
---|
| 69 | |
---|
| 70 | // Run the build |
---|
| 71 | // Don't propagate, it doesn't play nice with our email setup |
---|
[ae28ee2] | 72 | def result = build job: 'Cforall/master', \ |
---|
| 73 | parameters: [ \ |
---|
[8fa3c7e6] | 74 | [$class: 'StringParameterValue', \ |
---|
[0c1d240] | 75 | name: 'Compiler', \ |
---|
[8fa3c7e6] | 76 | value: cc], \ |
---|
| 77 | [$class: 'StringParameterValue', \ |
---|
[0c1d240] | 78 | name: 'Architecture', \ |
---|
[8fa3c7e6] | 79 | value: arch], \ |
---|
[849de65] | 80 | [$class: 'BooleanParameterValue', \ |
---|
| 81 | name: 'NewAST', \ |
---|
[ef1d025d] | 82 | value: true], \ |
---|
[ae28ee2] | 83 | [$class: 'BooleanParameterValue', \ |
---|
[0c1d240] | 84 | name: 'RunAllTests', \ |
---|
[8fa3c7e6] | 85 | value: true], \ |
---|
| 86 | [$class: 'BooleanParameterValue', \ |
---|
[0c1d240] | 87 | name: 'RunBenchmark', \ |
---|
[8fa3c7e6] | 88 | value: true], \ |
---|
| 89 | [$class: 'BooleanParameterValue', \ |
---|
[0c1d240] | 90 | name: 'BuildDocumentation', \ |
---|
[8fa3c7e6] | 91 | value: true], \ |
---|
| 92 | [$class: 'BooleanParameterValue', \ |
---|
[0c1d240] | 93 | name: 'Publish', \ |
---|
[849de65] | 94 | value: true], \ |
---|
[8fa3c7e6] | 95 | [$class: 'BooleanParameterValue', \ |
---|
[0c1d240] | 96 | name: 'Silent', \ |
---|
[ae28ee2] | 97 | value: true], \ |
---|
| 98 | ], \ |
---|
| 99 | propagate: false |
---|
| 100 | |
---|
| 101 | echo(result.result) |
---|
| 102 | |
---|
| 103 | if(result.result != 'SUCCESS') { |
---|
[27474a7] | 104 | sh("wget -q -O - http://localhost:8084/jenkins/job/Cforall/job/master/${result.number}/consoleText") |
---|
[ae28ee2] | 105 | error(result.result) |
---|
| 106 | } |
---|
| 107 | } |
---|
| 108 | |
---|
[6ae5c22] | 109 | def trigger_dist(String commitId, String buildNum) { |
---|
[b19fdb9] | 110 | def result = build job: 'Cforall_Distribute_Ref', \ |
---|
| 111 | parameters: [ \ |
---|
| 112 | string(name: 'GitRef', value: commitId), \ |
---|
[6ae5c22] | 113 | string(name: 'Build' , value: buildNum) \ |
---|
[587a608] | 114 | ], \ |
---|
| 115 | propagate: false |
---|
[b19fdb9] | 116 | |
---|
| 117 | echo(result.result) |
---|
| 118 | |
---|
| 119 | if(result.result != 'SUCCESS') { |
---|
| 120 | sh("wget -q -O - https://cforall.uwaterloo.ca/jenkins/job/Cforall_Distribute_Ref/${result.number}/consoleText") |
---|
| 121 | error(result.result) |
---|
| 122 | } |
---|
| 123 | } |
---|
| 124 | |
---|
[ae28ee2] | 125 | //=========================================================================================================== |
---|
| 126 | //Routine responsible of sending the email notification once the build is completed |
---|
| 127 | //=========================================================================================================== |
---|
| 128 | |
---|
| 129 | //Email notification on a full build failure |
---|
[13c98a4] | 130 | def promote_email(boolean success) { |
---|
[ae28ee2] | 131 | echo('notifying users') |
---|
| 132 | |
---|
[13c98a4] | 133 | def result = success ? "PROMOTE - SUCCESS" : "PROMOTE - FAILURE" |
---|
| 134 | |
---|
[ae28ee2] | 135 | //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line |
---|
| 136 | //Configurations for email format |
---|
[13c98a4] | 137 | def email_subject = "[cforall git][${result}]" |
---|
| 138 | def email_body = """<p>This is an automated email from the Jenkins build machine. It was |
---|
[986e260] | 139 | generated following the result of the C\u2200 nightly build.</p> |
---|
[13c98a4] | 140 | |
---|
| 141 | <p>Check console output at ${env.BUILD_URL} to view the results.</p> |
---|
| 142 | |
---|
| 143 | <p>- Status --------------------------------------------------------------</p> |
---|
[ae28ee2] | 144 | |
---|
[13c98a4] | 145 | <p>${result}</p> |
---|
[ae28ee2] | 146 | |
---|
[b7b573c] | 147 | <p>- Performance ---------------------------------------------------------</p> |
---|
[ae28ee2] | 148 | |
---|
[38c0fe5] | 149 | <img src="https://cforall.uwaterloo.ca/jenkins/job/Cforall/job/master/plot/Compilation/getPlot?index=0" > |
---|
[a74554af] | 150 | <img src="https://cforall.uwaterloo.ca/jenkins/job/Cforall/job/master/plot/Compilation/getPlot?index=1" > |
---|
[b7b573c] | 151 | |
---|
| 152 | <p>- Logs ----------------------------------------------------------------</p> |
---|
[ae28ee2] | 153 | """ |
---|
| 154 | |
---|
[e39647e] | 155 | def email_to = "cforall@lists.uwaterloo.ca" |
---|
[ae28ee2] | 156 | |
---|
| 157 | //send email notification |
---|
[13c98a4] | 158 | emailext body: email_body, subject: email_subject, to: email_to, attachLog: !success |
---|
[ae28ee2] | 159 | } |
---|