1 | #!groovy
|
---|
2 |
|
---|
3 | //===========================================================================================================
|
---|
4 | // Main compilation routines
|
---|
5 | //===========================================================================================================
|
---|
6 | def push_build() {
|
---|
7 | //Don't use the build_stage function which outputs the compiler
|
---|
8 | stage 'Push'
|
---|
9 |
|
---|
10 | status_prefix = 'Push'
|
---|
11 |
|
---|
12 | def out_dir = pwd tmp: true
|
---|
13 | sh "mkdir -p ${out_dir}"
|
---|
14 |
|
---|
15 | //parse git logs to find what changed
|
---|
16 | sh "git remote > ${out_dir}/GIT_REMOTE"
|
---|
17 | git_remote = readFile("${out_dir}/GIT_REMOTE")
|
---|
18 | remoteDoLangExists = git_remote.contains("DoLang")
|
---|
19 |
|
---|
20 | if( !remoteDoLangExists ) {
|
---|
21 | sh 'git remote add DoLang git@gitlab.do-lang.org:internal/cfa-cc.git'
|
---|
22 | }
|
---|
23 |
|
---|
24 | sh "git push DoLang ${gitRefNewValue}:master"
|
---|
25 | }
|
---|
26 |
|
---|
27 | //===========================================================================================================
|
---|
28 | // Main loop of the compilation
|
---|
29 | //===========================================================================================================
|
---|
30 | node ('master'){
|
---|
31 | try {
|
---|
32 | //Prevent the build from exceeding 30 minutes
|
---|
33 | timeout(60) {
|
---|
34 |
|
---|
35 | //Wrap build to add timestamp to command line
|
---|
36 | wrap([$class: 'TimestamperBuildWrapper']) {
|
---|
37 |
|
---|
38 | stage 'Build'
|
---|
39 |
|
---|
40 | parallel (
|
---|
41 | x64: { node ('master') {
|
---|
42 | build job: 'Cforall/master', \
|
---|
43 | parameters: [ \
|
---|
44 | [$class: 'BooleanParameterValue', \
|
---|
45 | name: 'isFullBuild', \
|
---|
46 | value: true], \
|
---|
47 | [$class: 'StringParameterValue', \
|
---|
48 | name: 'buildArchitecture', \
|
---|
49 | value: '64-bit'] \
|
---|
50 | ]
|
---|
51 | }},
|
---|
52 | x32: { node ('master') {
|
---|
53 | build job: 'Cforall/master', \
|
---|
54 | parameters: [ \
|
---|
55 | [$class: 'BooleanParameterValue', \
|
---|
56 | name: 'isFullBuild', \
|
---|
57 | value: true], \
|
---|
58 | [$class: 'StringParameterValue', \
|
---|
59 | name: 'buildArchitecture', \
|
---|
60 | value: '32-bit'] \
|
---|
61 | ]
|
---|
62 | }}
|
---|
63 | )
|
---|
64 |
|
---|
65 | //Push latest changes to do-lang repo
|
---|
66 | //push_build()
|
---|
67 | }
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | //If an exception is caught we need to change the status and remember to
|
---|
72 | //attach the build log to the email
|
---|
73 | catch (Exception caughtError) {
|
---|
74 | //rethrow error later
|
---|
75 | err = caughtError
|
---|
76 |
|
---|
77 | //Store the result of the build log
|
---|
78 | currentBuild.result = "${status_prefix} FAILURE".trim()
|
---|
79 |
|
---|
80 | //Send email to notify the failure
|
---|
81 | //promote_email(currentBuild.result)
|
---|
82 | }
|
---|
83 |
|
---|
84 | finally {
|
---|
85 | //Must re-throw exception to propagate error
|
---|
86 | if (err) {
|
---|
87 | throw err
|
---|
88 | }
|
---|
89 | }
|
---|
90 | }
|
---|
91 |
|
---|
92 | //===========================================================================================================
|
---|
93 | //Routine responsible of sending the email notification once the build is completed
|
---|
94 | //===========================================================================================================
|
---|
95 |
|
---|
96 | //Email notification on a full build failure
|
---|
97 | def promote_email(String status) {
|
---|
98 | //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
|
---|
99 | //Configurations for email format
|
---|
100 | def email_subject = "[cforall git][PROMOTE - FAILURE]"
|
---|
101 | def email_body = """This is an automated email from the Jenkins build machine. It was
|
---|
102 | generated because of a git hooks/post-receive script following
|
---|
103 | a ref change was pushed to the repository containing
|
---|
104 | the project "UNNAMED PROJECT".
|
---|
105 |
|
---|
106 | Check console output at ${env.BUILD_URL} to view the results.
|
---|
107 |
|
---|
108 | - Status --------------------------------------------------------------
|
---|
109 |
|
---|
110 | PROMOTE FAILURE - ${status}
|
---|
111 | """
|
---|
112 |
|
---|
113 | def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com"
|
---|
114 |
|
---|
115 | //send email notification
|
---|
116 | emailext body: email_body, subject: email_subject, to: email_to, attachLog: true
|
---|
117 | }
|
---|