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