1 | #!groovy |
---|
2 | |
---|
3 | node ('master') { |
---|
4 | |
---|
5 | user_email = '' |
---|
6 | test_list = '' |
---|
7 | |
---|
8 | prepare_build() |
---|
9 | |
---|
10 | try { |
---|
11 | |
---|
12 | stage('Checkout') { |
---|
13 | checkout scm |
---|
14 | |
---|
15 | sh 'git clean -xdf' |
---|
16 | |
---|
17 | sh 'git reset --hard' |
---|
18 | } |
---|
19 | |
---|
20 | stage('Building x86') { |
---|
21 | regen_tests('i386') |
---|
22 | } |
---|
23 | |
---|
24 | stage('Building x64') { |
---|
25 | regen_tests('x86_64') |
---|
26 | } |
---|
27 | |
---|
28 | stage('Patching') { |
---|
29 | make_patch() |
---|
30 | } |
---|
31 | |
---|
32 | stage('Email') { |
---|
33 | email() |
---|
34 | } |
---|
35 | } |
---|
36 | catch (Exception caughtError) { |
---|
37 | email_error() |
---|
38 | |
---|
39 | throw caughtError |
---|
40 | } |
---|
41 | } |
---|
42 | |
---|
43 | def prepare_build() { |
---|
44 | properties ([ \ |
---|
45 | [$class: 'ParametersDefinitionProperty', \ |
---|
46 | parameterDefinitions: [ \ |
---|
47 | [$class: 'StringParameterDefinition', \ |
---|
48 | description: 'Who required the test', \ |
---|
49 | name: 'pEmail', \ |
---|
50 | ], \ |
---|
51 | [$class: 'StringParameterDefinition', \ |
---|
52 | description: 'Space separated list of tests to run', \ |
---|
53 | name: 'pTests', \ |
---|
54 | ], \ |
---|
55 | ], |
---|
56 | ]]) |
---|
57 | |
---|
58 | user_email = pEmail; |
---|
59 | test_list = pTests; |
---|
60 | |
---|
61 | echo "User ${user_email} requested regenerating tests : ${ test_list }" |
---|
62 | } |
---|
63 | |
---|
64 | def regen_tests( String arch ) { |
---|
65 | |
---|
66 | def install_dir = pwd tmp: true |
---|
67 | |
---|
68 | //Configure the conpilation (Output is not relevant) |
---|
69 | //Use the current directory as the installation target so nothing |
---|
70 | //escapes the sandbox |
---|
71 | //Also specify the compiler by hand |
---|
72 | sh "./configure CXX=clang++ --host=${arch} --with-backend-compiler=gcc-6 --prefix=${install_dir} --enable-silent-rules --quiet" |
---|
73 | |
---|
74 | //Compile the project |
---|
75 | sh 'make -j 8 --no-print-directory install' |
---|
76 | |
---|
77 | //Regenerate the desired tests |
---|
78 | sh "src/tests/test.py --regenerate-expected ${test_list}" |
---|
79 | |
---|
80 | //Clean everything from the last build |
---|
81 | sh 'make maintainer-clean > /dev/null' |
---|
82 | } |
---|
83 | |
---|
84 | def make_patch() { |
---|
85 | |
---|
86 | def target_dir = pwd tmp: true |
---|
87 | |
---|
88 | //Add every file so new files appear in the diff |
---|
89 | sh 'git add .' |
---|
90 | |
---|
91 | //Create a patch file |
---|
92 | sh "git diff --cached --binary > ${target_dir}/result.patch" |
---|
93 | } |
---|
94 | |
---|
95 | def email() { |
---|
96 | |
---|
97 | def target_dir = pwd tmp: true |
---|
98 | |
---|
99 | dir( target_dir ) { |
---|
100 | |
---|
101 | def email_subject = "[cforall dashboard][TEST REGEN# ${env.BUILD_NUMBER}] - Result" |
---|
102 | def email_body = """This is an automated email from the Jenkins build machine. It was |
---|
103 | generated https://cforall.uwaterloo.ca:8082/dashboard.html. |
---|
104 | |
---|
105 | Please apply the required changes using the following method : |
---|
106 | - copy result.patch to your cforall repository of choice. |
---|
107 | - call 'git apply [patch file name]' (WARNING: the changes may conflict with any current changes to the test expected results). |
---|
108 | - validate that the changes are correct. |
---|
109 | - commit the changes as usual.""" |
---|
110 | |
---|
111 | //send email notification |
---|
112 | emailext body: email_body, subject: email_subject, to: user_email, attachmentsPattern: "**/*.patch" |
---|
113 | } |
---|
114 | } |
---|
115 | |
---|
116 | def email_error() { |
---|
117 | |
---|
118 | def email_subject = "[cforall dashboard][TEST REGEN# ${env.BUILD_NUMBER}] - FAILURE" |
---|
119 | def email_body = """This is an automated email from the Jenkins build machine. It was |
---|
120 | generated https://cforall.uwaterloo.ca:8082/dashboard.html. |
---|
121 | |
---|
122 | Test generation encoutered an error please see attached logs |
---|
123 | |
---|
124 | -----------------------------------------------------------------------""" |
---|
125 | |
---|
126 | //send email notification |
---|
127 | emailext body: email_body, subject: email_subject, to: user_email, attachLog: true |
---|
128 | } |
---|