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