source: Jenkins/TestRegen @ 7e492e4

ADTaaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 7e492e4 was 7e492e4, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

Fixed Jenkins email attachment pattern

  • Property mode set to 100644
File size: 2.6 KB
Line 
1#!groovy
2
3node ('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
43def 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
62def 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
82def 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
93def email() {
94
95        def email_subject = "[cforall dashboard][TEST REGEN# ${env.BUILD_NUMBER}] - Result"
96        def email_body = """This is an automated email from the Jenkins build machine. It was
97generated http://plg2:8082/dashboard."""
98
99        //send email notification
100        emailext body: email_body, subject: email_subject, to: user_email, attachmentsPattern: '**/result.patch'
101}
102
103def email_error() {
104
105        def email_subject = "[cforall dashboard][TEST REGEN# ${env.BUILD_NUMBER}] - FAILURE"
106        def email_body = """This is an automated email from the Jenkins build machine. It was
107generated http://plg2:8082/dashboard.
108
109Test generation encoutered an error please see attached logs
110
111-----------------------------------------------------------------------"""
112
113        //send email notification
114        emailext body: email_body, subject: email_subject, to: user_email, attachLog: true
115}
Note: See TracBrowser for help on using the repository browser.