[ae28ee2] | 1 | #!groovy |
---|
| 2 | |
---|
| 3 | //=========================================================================================================== |
---|
| 4 | // Main loop of the compilation |
---|
| 5 | //=========================================================================================================== |
---|
| 6 | |
---|
| 7 | node ('master') { |
---|
| 8 | def err = null |
---|
| 9 | |
---|
| 10 | try { |
---|
[f408e1a] | 11 | //Wrap build to add timestamp to command line |
---|
| 12 | wrap([$class: 'TimestamperBuildWrapper']) { |
---|
| 13 | |
---|
| 14 | stage('Build') { |
---|
| 15 | |
---|
| 16 | results = [null, null] |
---|
| 17 | |
---|
| 18 | parallel ( |
---|
[d056d0d] | 19 | clang_x86: { trigger_build( 'gcc-8', 'x86' ) }, |
---|
| 20 | gcc_5_x86: { trigger_build( 'gcc-7', 'x86' ) }, |
---|
[1b3eef8] | 21 | gcc_6_x86: { trigger_build( 'gcc-6', 'x86' ) }, |
---|
[b4a573c] | 22 | gcc_9_x64: { trigger_build( 'gcc-9', 'x64' ) }, |
---|
| 23 | gcc_8_x64: { trigger_build( 'gcc-8', 'x64' ) }, |
---|
| 24 | gcc_7_x64: { trigger_build( 'gcc-7', 'x64' ) }, |
---|
[d056d0d] | 25 | gcc_6_x64: { trigger_build( 'gcc-6', 'x64' ) }, |
---|
[1b3eef8] | 26 | gcc_5_x64: { trigger_build( 'gcc-5', 'x64' ) }, |
---|
| 27 | clang_x64: { trigger_build( 'clang', 'x64' ) }, |
---|
[f408e1a] | 28 | ) |
---|
[ae28ee2] | 29 | } |
---|
| 30 | } |
---|
[13c98a4] | 31 | |
---|
| 32 | promote_email(true) |
---|
[ae28ee2] | 33 | } |
---|
| 34 | |
---|
| 35 | //If an exception is caught we need to change the status and remember to |
---|
| 36 | //attach the build log to the email |
---|
| 37 | catch (Exception caughtError) { |
---|
| 38 | echo('error caught') |
---|
| 39 | |
---|
| 40 | //rethrow error later |
---|
| 41 | err = caughtError |
---|
| 42 | |
---|
| 43 | //Store the result of the build log |
---|
| 44 | currentBuild.result = 'FAILURE' |
---|
| 45 | |
---|
| 46 | //Send email to notify the failure |
---|
[13c98a4] | 47 | promote_email(false) |
---|
[ae28ee2] | 48 | } |
---|
| 49 | |
---|
| 50 | finally { |
---|
| 51 | //Must re-throw exception to propagate error |
---|
| 52 | if (err) { |
---|
| 53 | throw err |
---|
| 54 | } |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | //=========================================================================================================== |
---|
| 58 | // Main compilation routines |
---|
| 59 | //=========================================================================================================== |
---|
| 60 | |
---|
[c6a90bf] | 61 | def trigger_build(String cc, String arch) { |
---|
[ae28ee2] | 62 | def result = build job: 'Cforall/master', \ |
---|
| 63 | parameters: [ \ |
---|
[8fa3c7e6] | 64 | [$class: 'StringParameterValue', \ |
---|
[0c1d240] | 65 | name: 'Compiler', \ |
---|
[8fa3c7e6] | 66 | value: cc], \ |
---|
| 67 | [$class: 'StringParameterValue', \ |
---|
[0c1d240] | 68 | name: 'Architecture', \ |
---|
[8fa3c7e6] | 69 | value: arch], \ |
---|
[ae28ee2] | 70 | [$class: 'BooleanParameterValue', \ |
---|
[0c1d240] | 71 | name: 'RunAllTests', \ |
---|
[8fa3c7e6] | 72 | value: true], \ |
---|
| 73 | [$class: 'BooleanParameterValue', \ |
---|
[0c1d240] | 74 | name: 'RunBenchmark', \ |
---|
[8fa3c7e6] | 75 | value: true], \ |
---|
| 76 | [$class: 'BooleanParameterValue', \ |
---|
[0c1d240] | 77 | name: 'BuildDocumentation', \ |
---|
[8fa3c7e6] | 78 | value: true], \ |
---|
| 79 | [$class: 'BooleanParameterValue', \ |
---|
[0c1d240] | 80 | name: 'Publish', \ |
---|
[1b3eef8] | 81 | value: true], \ |
---|
[8fa3c7e6] | 82 | [$class: 'BooleanParameterValue', \ |
---|
[0c1d240] | 83 | name: 'Silent', \ |
---|
[ae28ee2] | 84 | value: true], \ |
---|
| 85 | ], \ |
---|
| 86 | propagate: false |
---|
| 87 | |
---|
| 88 | echo(result.result) |
---|
| 89 | |
---|
| 90 | if(result.result != 'SUCCESS') { |
---|
[27474a7] | 91 | sh("wget -q -O - http://localhost:8084/jenkins/job/Cforall/job/master/${result.number}/consoleText") |
---|
[ae28ee2] | 92 | error(result.result) |
---|
| 93 | } |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | //Helper routine to collect information about the git history |
---|
| 97 | def collect_git_info() { |
---|
| 98 | |
---|
| 99 | //create the temporary output directory in case it doesn't already exist |
---|
| 100 | def out_dir = pwd tmp: true |
---|
| 101 | sh "mkdir -p ${out_dir}" |
---|
| 102 | |
---|
| 103 | //parse git logs to find what changed |
---|
| 104 | dir("../Cforall_Full_Build@script") { |
---|
| 105 | sh "git reflog > ${out_dir}/GIT_COMMIT" |
---|
| 106 | } |
---|
| 107 | git_reflog = readFile("${out_dir}/GIT_COMMIT") |
---|
| 108 | gitRefOldValue = (git_reflog =~ /moving from (.+) to (.+)/)[0][1] |
---|
| 109 | gitRefNewValue = (git_reflog =~ /moving from (.+) to (.+)/)[0][2] |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | //=========================================================================================================== |
---|
| 113 | //Routine responsible of sending the email notification once the build is completed |
---|
| 114 | //=========================================================================================================== |
---|
| 115 | |
---|
| 116 | //Email notification on a full build failure |
---|
[13c98a4] | 117 | def promote_email(boolean success) { |
---|
[ae28ee2] | 118 | echo('notifying users') |
---|
| 119 | |
---|
[13c98a4] | 120 | def result = success ? "PROMOTE - SUCCESS" : "PROMOTE - FAILURE" |
---|
| 121 | |
---|
[ae28ee2] | 122 | //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line |
---|
| 123 | //Configurations for email format |
---|
[13c98a4] | 124 | def email_subject = "[cforall git][${result}]" |
---|
| 125 | def email_body = """<p>This is an automated email from the Jenkins build machine. It was |
---|
[986e260] | 126 | generated following the result of the C\u2200 nightly build.</p> |
---|
[13c98a4] | 127 | |
---|
| 128 | <p>Check console output at ${env.BUILD_URL} to view the results.</p> |
---|
| 129 | |
---|
| 130 | <p>- Status --------------------------------------------------------------</p> |
---|
[ae28ee2] | 131 | |
---|
[13c98a4] | 132 | <p>${result}</p> |
---|
[ae28ee2] | 133 | |
---|
[b7b573c] | 134 | <p>- Performance ---------------------------------------------------------</p> |
---|
[ae28ee2] | 135 | |
---|
[38c0fe5] | 136 | <img src="https://cforall.uwaterloo.ca/jenkins/job/Cforall/job/master/plot/Compilation/getPlot?index=0" > |
---|
[a74554af] | 137 | <img src="https://cforall.uwaterloo.ca/jenkins/job/Cforall/job/master/plot/Compilation/getPlot?index=1" > |
---|
[b7b573c] | 138 | |
---|
| 139 | <p>- Logs ----------------------------------------------------------------</p> |
---|
[ae28ee2] | 140 | """ |
---|
| 141 | |
---|
[e39647e] | 142 | def email_to = "cforall@lists.uwaterloo.ca" |
---|
[ae28ee2] | 143 | |
---|
| 144 | //send email notification |
---|
[13c98a4] | 145 | emailext body: email_body, subject: email_subject, to: email_to, attachLog: !success |
---|
[ae28ee2] | 146 | } |
---|