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