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 |
|
---|
31 | node ('master') {
|
---|
32 | try {
|
---|
33 | //Prevent the build from exceeding 30 minutes
|
---|
34 | timeout(60) {
|
---|
35 |
|
---|
36 | //Wrap build to add timestamp to command line
|
---|
37 | wrap([$class: 'TimestamperBuildWrapper']) {
|
---|
38 |
|
---|
39 | stage 'Build'
|
---|
40 |
|
---|
41 | results = [null, null]
|
---|
42 |
|
---|
43 | parallel (
|
---|
44 | x64: {
|
---|
45 | results[0] = build job: 'Cforall/master', \
|
---|
46 | parameters: [ \
|
---|
47 | [$class: 'BooleanParameterValue', \
|
---|
48 | name: 'isFullBuild', \
|
---|
49 | value: true], \
|
---|
50 | [$class: 'StringParameterValue', \
|
---|
51 | name: 'buildArchitecture', \
|
---|
52 | value: '64-bit'] \
|
---|
53 | ]
|
---|
54 | },
|
---|
55 | x32:
|
---|
56 | {
|
---|
57 | results[1] = build job: 'Cforall/master', \
|
---|
58 | parameters: [ \
|
---|
59 | [$class: 'BooleanParameterValue', \
|
---|
60 | name: 'isFullBuild', \
|
---|
61 | value: true], \
|
---|
62 | [$class: 'StringParameterValue', \
|
---|
63 | name: 'buildArchitecture', \
|
---|
64 | value: '32-bit'] \
|
---|
65 | ]
|
---|
66 | }
|
---|
67 | )
|
---|
68 |
|
---|
69 | results.each { result ->
|
---|
70 | echo(result.result)
|
---|
71 | echo(result.absoluteUrl)
|
---|
72 |
|
---|
73 | if (result.result != 'SUCCESS') {
|
---|
74 | echo( 'Build Succede' )
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 | //Push latest changes to do-lang repo
|
---|
79 | push_build()
|
---|
80 | }
|
---|
81 | }
|
---|
82 | }
|
---|
83 |
|
---|
84 | //If an exception is caught we need to change the status and remember to
|
---|
85 | //attach the build log to the email
|
---|
86 | catch (Exception caughtError) {
|
---|
87 | //rethrow error later
|
---|
88 | err = caughtError
|
---|
89 |
|
---|
90 | //Store the result of the build log
|
---|
91 | currentBuild.result = "${status_prefix} FAILURE".trim()
|
---|
92 |
|
---|
93 | //Send email to notify the failure
|
---|
94 | promote_email(currentBuild.result)
|
---|
95 | }
|
---|
96 |
|
---|
97 | finally {
|
---|
98 | //Must re-throw exception to propagate error
|
---|
99 | if (err) {
|
---|
100 | throw err
|
---|
101 | }
|
---|
102 | }
|
---|
103 | }
|
---|
104 | //===========================================================================================================
|
---|
105 | //Routine responsible of sending the email notification once the build is completed
|
---|
106 | //===========================================================================================================
|
---|
107 |
|
---|
108 | //Email notification on a full build failure
|
---|
109 | def promote_email(String status) {
|
---|
110 | //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
|
---|
111 | //Configurations for email format
|
---|
112 | def email_subject = "[cforall git][PROMOTE - FAILURE]"
|
---|
113 | def email_body = """This is an automated email from the Jenkins build machine. It was
|
---|
114 | generated because of a git hooks/post-receive script following
|
---|
115 | a ref change was pushed to the repository containing
|
---|
116 | the project "UNNAMED PROJECT".
|
---|
117 |
|
---|
118 | Check console output at ${env.BUILD_URL} to view the results.
|
---|
119 |
|
---|
120 | - Status --------------------------------------------------------------
|
---|
121 |
|
---|
122 | PROMOTE FAILURE - ${status}
|
---|
123 | """
|
---|
124 |
|
---|
125 | def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com"
|
---|
126 |
|
---|
127 | //send email notification
|
---|
128 | emailext body: email_body, subject: email_subject, to: email_to, attachLog: true
|
---|
129 | }
|
---|