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