1 | #!groovy |
---|
2 | |
---|
3 | //=========================================================================================================== |
---|
4 | // Main loop of the compilation |
---|
5 | //=========================================================================================================== |
---|
6 | |
---|
7 | node ('master') { |
---|
8 | def err = null |
---|
9 | |
---|
10 | final commitId = sh(returnStdout: true, script: 'git rev-parse HEAD') |
---|
11 | |
---|
12 | try { |
---|
13 | //Wrap build to add timestamp to command line |
---|
14 | wrap([$class: 'TimestamperBuildWrapper']) { |
---|
15 | |
---|
16 | stage('Build') { |
---|
17 | |
---|
18 | results = [null, null] |
---|
19 | |
---|
20 | parallel ( |
---|
21 | gcc_8_x86_old: { trigger_build( 'gcc-8', 'x86', false ) }, |
---|
22 | gcc_7_x86_old: { trigger_build( 'gcc-7', 'x86', false ) }, |
---|
23 | gcc_6_x86_old: { trigger_build( 'gcc-6', 'x86', false ) }, |
---|
24 | gcc_9_x64_old: { trigger_build( 'gcc-9', 'x64', false ) }, |
---|
25 | gcc_8_x64_old: { trigger_build( 'gcc-8', 'x64', false ) }, |
---|
26 | gcc_7_x64_old: { trigger_build( 'gcc-7', 'x64', false ) }, |
---|
27 | gcc_6_x64_old: { trigger_build( 'gcc-6', 'x64', false ) }, |
---|
28 | gcc_5_x64_old: { trigger_build( 'gcc-5', 'x64', false ) }, |
---|
29 | clang_x64_old: { trigger_build( 'clang', 'x64', false ) }, |
---|
30 | clang_x64_new: { trigger_build( 'clang', 'x64', true ) }, |
---|
31 | ) |
---|
32 | } |
---|
33 | |
---|
34 | stage('Package') { |
---|
35 | build job: 'Cforall_Distribute_Ref', parameters: [string(name: 'GitRef', value: commitId), string(name: 'Build', value: currentBuild.number)] |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | promote_email(true) |
---|
40 | } |
---|
41 | |
---|
42 | //If an exception is caught we need to change the status and remember to |
---|
43 | //attach the build log to the email |
---|
44 | catch (Exception caughtError) { |
---|
45 | echo('error caught') |
---|
46 | |
---|
47 | //rethrow error later |
---|
48 | err = caughtError |
---|
49 | |
---|
50 | //Store the result of the build log |
---|
51 | currentBuild.result = 'FAILURE' |
---|
52 | |
---|
53 | //Send email to notify the failure |
---|
54 | promote_email(false) |
---|
55 | } |
---|
56 | |
---|
57 | finally { |
---|
58 | //Must re-throw exception to propagate error |
---|
59 | if (err) { |
---|
60 | throw err |
---|
61 | } |
---|
62 | } |
---|
63 | } |
---|
64 | //=========================================================================================================== |
---|
65 | // Main compilation routines |
---|
66 | //=========================================================================================================== |
---|
67 | |
---|
68 | def trigger_build(String cc, String arch, boolean new_ast) { |
---|
69 | def result = build job: 'Cforall/master', \ |
---|
70 | parameters: [ \ |
---|
71 | [$class: 'StringParameterValue', \ |
---|
72 | name: 'Compiler', \ |
---|
73 | value: cc], \ |
---|
74 | [$class: 'StringParameterValue', \ |
---|
75 | name: 'Architecture', \ |
---|
76 | value: arch], \ |
---|
77 | [$class: 'BooleanParameterValue', \ |
---|
78 | name: 'NewAST', \ |
---|
79 | value: new_ast], \ |
---|
80 | [$class: 'BooleanParameterValue', \ |
---|
81 | name: 'RunAllTests', \ |
---|
82 | value: true], \ |
---|
83 | [$class: 'BooleanParameterValue', \ |
---|
84 | name: 'RunBenchmark', \ |
---|
85 | value: true], \ |
---|
86 | [$class: 'BooleanParameterValue', \ |
---|
87 | name: 'BuildDocumentation', \ |
---|
88 | value: true], \ |
---|
89 | [$class: 'BooleanParameterValue', \ |
---|
90 | name: 'Publish', \ |
---|
91 | value: true], \ |
---|
92 | [$class: 'BooleanParameterValue', \ |
---|
93 | name: 'Silent', \ |
---|
94 | value: true], \ |
---|
95 | ], \ |
---|
96 | propagate: false |
---|
97 | |
---|
98 | echo(result.result) |
---|
99 | |
---|
100 | if(result.result != 'SUCCESS') { |
---|
101 | sh("wget -q -O - http://localhost:8084/jenkins/job/Cforall/job/master/${result.number}/consoleText") |
---|
102 | error(result.result) |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | //=========================================================================================================== |
---|
107 | //Routine responsible of sending the email notification once the build is completed |
---|
108 | //=========================================================================================================== |
---|
109 | |
---|
110 | //Email notification on a full build failure |
---|
111 | def promote_email(boolean success) { |
---|
112 | echo('notifying users') |
---|
113 | |
---|
114 | def result = success ? "PROMOTE - SUCCESS" : "PROMOTE - FAILURE" |
---|
115 | |
---|
116 | //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line |
---|
117 | //Configurations for email format |
---|
118 | def email_subject = "[cforall git][${result}]" |
---|
119 | def email_body = """<p>This is an automated email from the Jenkins build machine. It was |
---|
120 | generated following the result of the C\u2200 nightly build.</p> |
---|
121 | |
---|
122 | <p>Check console output at ${env.BUILD_URL} to view the results.</p> |
---|
123 | |
---|
124 | <p>- Status --------------------------------------------------------------</p> |
---|
125 | |
---|
126 | <p>${result}</p> |
---|
127 | |
---|
128 | <p>- Performance ---------------------------------------------------------</p> |
---|
129 | |
---|
130 | <img src="https://cforall.uwaterloo.ca/jenkins/job/Cforall/job/master/plot/Compilation/getPlot?index=0" > |
---|
131 | <img src="https://cforall.uwaterloo.ca/jenkins/job/Cforall/job/master/plot/Compilation/getPlot?index=1" > |
---|
132 | |
---|
133 | <p>- Logs ----------------------------------------------------------------</p> |
---|
134 | """ |
---|
135 | |
---|
136 | def email_to = "cforall@lists.uwaterloo.ca" |
---|
137 | |
---|
138 | //send email notification |
---|
139 | emailext body: email_body, subject: email_subject, to: email_to, attachLog: !success |
---|
140 | } |
---|