def build() { build_stage 'Checkout' def install_dir = pwd tmp: true //checkout the source code and clean the repo sh "rm -rf * ${install_dir}/*" checkout scm build_stage 'Build' //Configure the conpilation (Output is not relevant) //Use the current directory as the installation target so nothing //escapes the sandbox //Also specify the compiler by hand sh "./configure CXX=${currentCC.cpp-cc} --with-backend-compiler=${currentCC.cfa-backend-cc} --prefix=${install_dir} > /dev/null" //Compile the project sh 'make -j 8 install' build_stage 'Test' status_prefix = 'Test' dir ('src/examples') { sh './runTests.sh' } build_stage 'Cleanup' //install doesn't need to be cleaned since prefix uses temporary workspace } class CC_Desc { String name String cpp-cc String cfa-backend-cc } def currentCC def build_stage(String name) { def stage_name = "${currentCC.name} ${name}".trim() stage stage_name status_prefix = stage_name } node ('master'){ def err = null def status_prefix def log_needed = false currentBuild.result = "SUCCESS" try { currentCC = ['gcc-4.9', 'g++-4.9', 'gcc-4.9'] as CC_Desc build() } catch (Exception caughtError) { err = caughtError log_needed = true currentBuild.result = "${status_prefix} FAILURE".trim() } finally { //Send email with final results email(currentBuild.result, log_needed) /* Must re-throw exception to propagate error */ if (err) { throw err } } } def email(String status, boolean log) { //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line //Configurations for email format def project_name = (env.JOB_NAME =~ /(.+)\/.+/)[0][1].toLowerCase() def email_subject = "[${project_name} git][BUILD# ${env.BUILD_NUMBER} - ${status}] - branch ${env.BRANCH_NAME}" def email_body = """This is an automated email from the Jenkins build machine. It was generated because of a git hooks/post-receive script following a ref change was pushed to the repository containing the project "UNNAMED PROJECT". The branch ${env.BRANCH_NAME} has been updated. Check console output at ${env.BUILD_URL} to view the results.""" // def config = new File('/u/cforall/software/cfa/cfa-cc/config').text // def email_to = (config =~ /mailinglist ?= ?(.+)/)[0][1] def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com" //send email notification emailext body: email_body, subject: email_subject, to: email_to, attachLog: log }