1 | |
---|
2 | def build() { |
---|
3 | build_stage 'Checkout' |
---|
4 | def install_dir = pwd tmp: true |
---|
5 | //checkout the source code and clean the repo |
---|
6 | sh "rm -rf * ${install_dir}/*" |
---|
7 | checkout scm |
---|
8 | |
---|
9 | build_stage 'Build' |
---|
10 | |
---|
11 | //Configure the conpilation (Output is not relevant) |
---|
12 | //Use the current directory as the installation target so nothing |
---|
13 | //escapes the sandbox |
---|
14 | //Also specify the compiler by hand |
---|
15 | sh "./configure CXX=${currentCC.cpp-cc} --with-backend-compiler=${currentCC.cfa-backend-cc} --prefix=${install_dir} > /dev/null" |
---|
16 | |
---|
17 | //Compile the project |
---|
18 | sh 'make -j 8 install' |
---|
19 | |
---|
20 | build_stage 'Test' |
---|
21 | |
---|
22 | status_prefix = 'Test' |
---|
23 | |
---|
24 | dir ('src/examples') { |
---|
25 | sh './runTests.sh' |
---|
26 | } |
---|
27 | |
---|
28 | build_stage 'Cleanup' |
---|
29 | |
---|
30 | //install doesn't need to be cleaned since prefix uses temporary workspace |
---|
31 | } |
---|
32 | |
---|
33 | class CC_Desc { |
---|
34 | String name |
---|
35 | String cpp-cc |
---|
36 | String cfa-backend-cc |
---|
37 | } |
---|
38 | |
---|
39 | def currentCC |
---|
40 | |
---|
41 | def build_stage(String name) { |
---|
42 | def stage_name = "${currentCC.name} ${name}".trim() |
---|
43 | stage stage_name |
---|
44 | |
---|
45 | status_prefix = stage_name |
---|
46 | } |
---|
47 | |
---|
48 | node ('master'){ |
---|
49 | |
---|
50 | def err = null |
---|
51 | def status_prefix |
---|
52 | def log_needed = false |
---|
53 | currentBuild.result = "SUCCESS" |
---|
54 | |
---|
55 | try { |
---|
56 | currentCC = ['gcc-4.9', 'g++-4.9', 'gcc-4.9'] as CC_Desc |
---|
57 | build() |
---|
58 | |
---|
59 | } |
---|
60 | |
---|
61 | catch (Exception caughtError) { |
---|
62 | err = caughtError |
---|
63 | log_needed = true |
---|
64 | currentBuild.result = "${status_prefix} FAILURE".trim() |
---|
65 | } |
---|
66 | |
---|
67 | finally { |
---|
68 | //Send email with final results |
---|
69 | email(currentBuild.result, log_needed) |
---|
70 | |
---|
71 | /* Must re-throw exception to propagate error */ |
---|
72 | if (err) { |
---|
73 | throw err |
---|
74 | } |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | def email(String status, boolean log) { |
---|
79 | //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line |
---|
80 | //Configurations for email format |
---|
81 | def project_name = (env.JOB_NAME =~ /(.+)\/.+/)[0][1].toLowerCase() |
---|
82 | |
---|
83 | def email_subject = "[${project_name} git][BUILD# ${env.BUILD_NUMBER} - ${status}] - branch ${env.BRANCH_NAME}" |
---|
84 | def email_body = """This is an automated email from the Jenkins build machine. It was |
---|
85 | generated because of a git hooks/post-receive script following |
---|
86 | a ref change was pushed to the repository containing |
---|
87 | the project "UNNAMED PROJECT". |
---|
88 | |
---|
89 | The branch ${env.BRANCH_NAME} has been updated. |
---|
90 | |
---|
91 | Check console output at ${env.BUILD_URL} to view the results.""" |
---|
92 | |
---|
93 | // def config = new File('/u/cforall/software/cfa/cfa-cc/config').text |
---|
94 | // def email_to = (config =~ /mailinglist ?= ?(.+)/)[0][1] |
---|
95 | def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com" |
---|
96 | |
---|
97 | //send email notification |
---|
98 | emailext body: email_body, subject: email_subject, to: email_to, attachLog: log |
---|
99 | } |
---|