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