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 | |
---|
62 | def regen_tests( String arch ) { |
---|
63 | |
---|
64 | def install_dir = pwd tmp: true |
---|
65 | |
---|
66 | //Configure the conpilation (Output is not relevant) |
---|
67 | //Use the current directory as the installation target so nothing |
---|
68 | //escapes the sandbox |
---|
69 | //Also specify the compiler by hand |
---|
70 | sh "./configure CXX=clang++ --host=${arch} --with-backend-compiler=gcc-6 --prefix=${install_dir} --enable-silent-rules --quiet" |
---|
71 | |
---|
72 | //Compile the project |
---|
73 | sh 'make -j 8 --no-print-directory install' |
---|
74 | |
---|
75 | //Regenerate the desired tests |
---|
76 | sh "src/tests/test.py --regenerate-expected ${test_list}" |
---|
77 | |
---|
78 | //Clean everything from the last build |
---|
79 | sh 'make maintainer-clean > /dev/null' |
---|
80 | } |
---|
81 | |
---|
82 | def make_patch() { |
---|
83 | |
---|
84 | def target_dir = pwd tmp: true |
---|
85 | |
---|
86 | //Add every file so new files appear in the diff |
---|
87 | sh 'git add .' |
---|
88 | |
---|
89 | //Create a patch file |
---|
90 | sh "git diff --cached --binary > ${target_dir}/result.patch" |
---|
91 | } |
---|
92 | |
---|
93 | def email() { |
---|
94 | |
---|
95 | def target_dir = pwd tmp: true |
---|
96 | |
---|
97 | dir( target_dir ) { |
---|
98 | |
---|
99 | def email_subject = "[cforall dashboard][TEST REGEN# ${env.BUILD_NUMBER}] - Result" |
---|
100 | def email_body = """This is an automated email from the Jenkins build machine. It was |
---|
101 | generated http://plg2:8082/dashboard. |
---|
102 | |
---|
103 | Please apply the required changes using the following method : |
---|
104 | - copy result.patch to your cforall repository of choice. |
---|
105 | - call 'git apply [patch file name]' (WARNING: the changes may conflict with any current changes to the test expected results). |
---|
106 | - validate that the changes are correct. |
---|
107 | - commit the changes as usual.""" |
---|
108 | |
---|
109 | //send email notification |
---|
110 | emailext body: email_body, subject: email_subject, to: user_email, attachmentsPattern: "**/*.patch" |
---|
111 | } |
---|
112 | } |
---|
113 | |
---|
114 | def email_error() { |
---|
115 | |
---|
116 | def email_subject = "[cforall dashboard][TEST REGEN# ${env.BUILD_NUMBER}] - FAILURE" |
---|
117 | def email_body = """This is an automated email from the Jenkins build machine. It was |
---|
118 | generated http://plg2:8082/dashboard. |
---|
119 | |
---|
120 | Test generation encoutered an error please see attached logs |
---|
121 | |
---|
122 | -----------------------------------------------------------------------""" |
---|
123 | |
---|
124 | //send email notification |
---|
125 | emailext body: email_body, subject: email_subject, to: user_email, attachLog: true |
---|
126 | } |
---|