| 1 |
|
|---|
| 2 |
|
|---|
| 3 | //checkout the source code and clean the repo
|
|---|
| 4 | stage 'Checkout'
|
|---|
| 5 | node {
|
|---|
| 6 | checkout scm
|
|---|
| 7 | sh 'git clean -dfq'
|
|---|
| 8 | }
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | stage 'Build'
|
|---|
| 12 | node ('master'){
|
|---|
| 13 | try {
|
|---|
| 14 | //configure the conpilation
|
|---|
| 15 | //Don't remove outputs for the clean and configure unless errors are present
|
|---|
| 16 | sh 'make clean > /dev/null'
|
|---|
| 17 | sh 'CC=gcc-4.9 CXX=g++-4.9 ./configure > /dev/null'
|
|---|
| 18 | sh 'make -j 8'
|
|---|
| 19 |
|
|---|
| 20 | //something happen, this build is a failure
|
|---|
| 21 | } catch (Exception e) {
|
|---|
| 22 | email("COMPILATION FAILURE", true)
|
|---|
| 23 | throw e;
|
|---|
| 24 | }
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | stage 'Test'
|
|---|
| 28 | node ('master'){
|
|---|
| 29 | try {
|
|---|
| 30 | dir 'src/example'
|
|---|
| 31 | sh './runTests.sh'
|
|---|
| 32 | dir '../..'
|
|---|
| 33 | email("SUCCESS", false)
|
|---|
| 34 | //something happen, this build is a failure
|
|---|
| 35 | } catch (Exception e) {
|
|---|
| 36 | email("TEST FAILURE", true)
|
|---|
| 37 | throw e;
|
|---|
| 38 | }
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | def email(String status, boolean log) {
|
|---|
| 42 | //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
|
|---|
| 43 | //Configurations for email format
|
|---|
| 44 | def project_name = (env.JOB_NAME =~ /(.+)\/.+/)[0][1].toLowerCase()
|
|---|
| 45 |
|
|---|
| 46 | def email_subject = "[${project_name} git] UNNAMED PROJECT branch ${env.BRANCH_NAME} - Build # ${env.BUILD_NUMBER} - ${status}!"
|
|---|
| 47 | def email_body = """ This is an automated email from the Jenkins build machine. It was
|
|---|
| 48 | generated because of a git hooks/post-receive script following
|
|---|
| 49 | a ref change was pushed to the repository containing
|
|---|
| 50 | the project "UNNAMED PROJECT".
|
|---|
| 51 |
|
|---|
| 52 | The branch ${env.BRANCH_NAME} has been updated.
|
|---|
| 53 |
|
|---|
| 54 | Check console output at ${env.BUILD_URL} to view the results."""
|
|---|
| 55 |
|
|---|
| 56 | // def config = new File('/u/cforall/software/cfa/cfa-cc/config').text
|
|---|
| 57 | // def email_to = (config =~ /mailinglist ?= ?(.+)/)[0][1]
|
|---|
| 58 | def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com"
|
|---|
| 59 |
|
|---|
| 60 | //send email notification
|
|---|
| 61 | emailext body: email_body, subject: email_subject, to: email_to, attachLog: log
|
|---|
| 62 | }
|
|---|