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