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