[1b8c156] | 1 | #!groovy |
---|
| 2 | |
---|
[6003581] | 3 | //=========================================================================================================== |
---|
| 4 | // Main compilation routines |
---|
| 5 | //=========================================================================================================== |
---|
[1b8c156] | 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 | |
---|
[6003581] | 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 | build job: 'Cforall/master', \ |
---|
| 39 | parameters: [ \ |
---|
| 40 | [$class: 'BooleanParameterValue', \ |
---|
| 41 | name: 'isFullBuild', \ |
---|
| 42 | value: true], \ |
---|
| 43 | [$class: 'StringParameterValue', \ |
---|
| 44 | name: 'buildArchitecture', \ |
---|
| 45 | value: '64-bit'] \ |
---|
| 46 | ] |
---|
| 47 | |
---|
| 48 | //Push latest changes to do-lang repo |
---|
| 49 | //push_build() |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | //If an exception is caught we need to change the status and remember to |
---|
| 55 | //attach the build log to the email |
---|
| 56 | catch (Exception caughtError) { |
---|
| 57 | //rethrow error later |
---|
| 58 | err = caughtError |
---|
| 59 | |
---|
| 60 | //Store the result of the build log |
---|
| 61 | currentBuild.result = "${status_prefix} FAILURE".trim() |
---|
| 62 | |
---|
| 63 | //Send email to notify the failure |
---|
| 64 | //promote_email(currentBuild.result) |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | finally { |
---|
| 68 | //Must re-throw exception to propagate error |
---|
| 69 | if (err) { |
---|
| 70 | throw err |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | //=========================================================================================================== |
---|
| 76 | //Routine responsible of sending the email notification once the build is completed |
---|
| 77 | //=========================================================================================================== |
---|
[1b8c156] | 78 | |
---|
| 79 | //Email notification on a full build failure |
---|
| 80 | def promote_email(String status) { |
---|
| 81 | //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line |
---|
| 82 | //Configurations for email format |
---|
| 83 | def email_subject = "[cforall git][PROMOTE - FAILURE]" |
---|
| 84 | def email_body = """This is an automated email from the Jenkins build machine. It was |
---|
| 85 | generated because of a git hooks/post-receive script following |
---|
| 86 | a ref change was pushed to the repository containing |
---|
| 87 | the project "UNNAMED PROJECT". |
---|
| 88 | |
---|
| 89 | Check console output at ${env.BUILD_URL} to view the results. |
---|
| 90 | |
---|
| 91 | - Status -------------------------------------------------------------- |
---|
| 92 | |
---|
| 93 | PROMOTE FAILURE - ${status} |
---|
| 94 | """ |
---|
| 95 | |
---|
| 96 | def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com" |
---|
| 97 | |
---|
| 98 | //send email notification |
---|
| 99 | emailext body: email_body, subject: email_subject, to: email_to, attachLog: true |
---|
| 100 | } |
---|