source: Jenkins/FullBuild

Last change on this file was da10157, checked in by Peter A. Buhr <pabuhr@…>, 8 weeks ago

start updating Jenkins for Ubuntu 24.04

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