source: Jenkins/FullBuild@ 8e70823

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr persistent-indexer pthread-emulation qualifiedEnum
Last change on this file since 8e70823 was 0c1d240, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Tentative to fix parameters on first build of branch

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