source: Jenkins/FullBuild @ 0d10090

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

Jenkins now only publishes once per full build (per architecture)

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