source: Jenkins/FullBuild @ d2f5469

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since d2f5469 was d2f5469, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Fullbuild should now properly display errors on failure

  • Property mode set to 100644
File size: 4.4 KB
Line 
1#!groovy
2
3//===========================================================================================================
4// Main compilation routines
5//===========================================================================================================
6
7def trigger_build(String arch) {
8        def result = build job: 'Cforall/master',               \
9                parameters: [                                           \
10                        [$class: 'BooleanParameterValue',               \
11                          name: 'isFullBuild',                          \
12                          value: true],                                         \
13                        [$class: 'StringParameterValue',                \
14                          name: 'buildArchitecture',                    \
15                          value: arch],                                 \
16                propagate: false]
17
18        echo(result.result)
19        if(result.result != 'SUCCESS') {
20                sh("wget -q -O - ${result.absoluteUrl}/consoleText")
21        }
22}
23
24def push_build() {
25        //Don't use the build_stage function which outputs the compiler
26        stage 'Push'
27
28                status_prefix = 'Push'
29
30                def out_dir = pwd tmp: true
31                sh "mkdir -p ${out_dir}"
32
33                //checkout the code to make sure this is a valid git repo
34                checkout scm
35
36                collect_git_info()
37
38                //parse git logs to find what changed
39                sh "git remote > ${out_dir}/GIT_REMOTE"
40                git_remote = readFile("${out_dir}/GIT_REMOTE")
41                remoteDoLangExists = git_remote.contains("DoLang")
42
43                if( !remoteDoLangExists ) {
44                        sh 'git remote add DoLang git@gitlab.do-lang.org:internal/cfa-cc.git'
45                }
46
47                //sh "GIT_SSH_COMMAND=\"ssh -v\" git push DoLang ${gitRefNewValue}:master"
48                echo('BUILD NOT PUSH SINCE DO-LANG SERVER WAS DOWN')
49}
50
51//Helper routine to collect information about the git history
52def collect_git_info() {
53
54        //create the temporary output directory in case it doesn't already exist
55        def out_dir = pwd tmp: true
56        sh "mkdir -p ${out_dir}"
57
58        //parse git logs to find what changed
59        dir("../Cforall_Full_Build@script") {
60                sh "git reflog > ${out_dir}/GIT_COMMIT"
61        }
62        git_reflog = readFile("${out_dir}/GIT_COMMIT")
63        gitRefOldValue = (git_reflog =~ /moving from (.+) to (.+)/)[0][1]
64        gitRefNewValue = (git_reflog =~ /moving from (.+) to (.+)/)[0][2]
65}
66
67//===========================================================================================================
68// Main loop of the compilation
69//===========================================================================================================
70
71node ('master') {
72        def err = null
73
74        try {
75                //Prevent the build from exceeding 30 minutes
76                timeout(60) {
77
78                        //Wrap build to add timestamp to command line
79                        wrap([$class: 'TimestamperBuildWrapper']) {
80
81                                stage 'Build'
82
83                                        results = [null, null]
84
85                                        parallel (
86                                                x64: {
87                                                        trigger_build('64-bit')
88                                                },
89                                                x32: {
90                                                        trigger_build('32-bit')
91                                                }
92                                        )
93
94                                //Push latest changes to do-lang repo
95                                push_build()
96                        }
97                }
98        }
99
100        //If an exception is caught we need to change the status and remember to
101        //attach the build log to the email
102        catch (Exception caughtError) {
103                echo('error caught')
104
105                //rethrow error later
106                err = caughtError
107
108                //Store the result of the build log
109                currentBuild.result = 'FAILURE'
110
111                //Send email to notify the failure
112                promote_failure_email()
113        }
114
115        finally {
116                //Must re-throw exception to propagate error
117                if (err) {
118                        throw err
119                }
120        }
121}
122//===========================================================================================================
123//Routine responsible of sending the email notification once the build is completed
124//===========================================================================================================
125
126//Email notification on a full build failure
127def promote_failure_email() {
128        echo('notifying users')
129
130        //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
131        //Configurations for email format
132        def email_subject = "[cforall git][PROMOTE - FAILURE]"
133        def email_body = """This is an automated email from the Jenkins build machine. It was
134generated because of a git hooks/post-receive script following
135a ref change was pushed to the repository containing
136the project "UNNAMED PROJECT".
137
138Check console output at ${env.BUILD_URL} to view the results.
139
140- Status --------------------------------------------------------------
141
142PROMOTE FAILURE
143"""
144
145        def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com"
146
147        //send email notification
148        emailext body: email_body, subject: email_subject, to: email_to, attachLog: true
149}
Note: See TracBrowser for help on using the repository browser.