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