#!groovy //=========================================================================================================== // Main loop of the compilation //=========================================================================================================== node ('master') { def err = null final scmVars = checkout scm final commitId = scmVars.GIT_COMMIT try { //Wrap build to add timestamp to command line wrap([$class: 'TimestamperBuildWrapper']) { stage('Build') { parallel ( gcc_8_x86_old: { trigger_build( 'gcc-8', 'x86', false ) }, gcc_7_x86_old: { trigger_build( 'gcc-7', 'x86', false ) }, gcc_6_x86_old: { trigger_build( 'gcc-6', 'x86', false ) }, gcc_9_x64_old: { trigger_build( 'gcc-9', 'x64', false ) }, gcc_8_x64_old: { trigger_build( 'gcc-8', 'x64', false ) }, gcc_7_x64_old: { trigger_build( 'gcc-7', 'x64', false ) }, gcc_6_x64_old: { trigger_build( 'gcc-6', 'x64', false ) }, gcc_5_x64_old: { trigger_build( 'gcc-5', 'x64', false ) }, clang_x64_old: { trigger_build( 'clang', 'x64', false ) }, clang_x64_new: { trigger_build( 'clang', 'x64', true ) }, ) } stage('Package') { trigger_dist( commitId, currentBuild.number.toString() ) } } promote_email(true) } //If an exception is caught we need to change the status and remember to //attach the build log to the email catch (Exception caughtError) { echo('error caught') //rethrow error later err = caughtError //Store the result of the build log currentBuild.result = 'FAILURE' //Send email to notify the failure promote_email(false) } finally { //Must re-throw exception to propagate error if (err) { throw err } } } //=========================================================================================================== // Main compilation routines //=========================================================================================================== def trigger_build(String cc, String arch, boolean new_ast) { def result = build job: 'Cforall/master', \ parameters: [ \ [$class: 'StringParameterValue', \ name: 'Compiler', \ value: cc], \ [$class: 'StringParameterValue', \ name: 'Architecture', \ value: arch], \ [$class: 'BooleanParameterValue', \ name: 'NewAST', \ value: new_ast], \ [$class: 'BooleanParameterValue', \ name: 'RunAllTests', \ value: true], \ [$class: 'BooleanParameterValue', \ name: 'RunBenchmark', \ value: true], \ [$class: 'BooleanParameterValue', \ name: 'BuildDocumentation', \ value: true], \ [$class: 'BooleanParameterValue', \ name: 'Publish', \ value: true], \ [$class: 'BooleanParameterValue', \ name: 'Silent', \ value: true], \ ], \ propagate: false echo(result.result) if(result.result != 'SUCCESS') { sh("wget -q -O - http://localhost:8084/jenkins/job/Cforall/job/master/${result.number}/consoleText") error(result.result) } } def trigger_dist(String commitId, String buildNum) { def result = build job: 'Cforall_Distribute_Ref', \ parameters: [ \ string(name: 'GitRef', value: commitId), \ string(name: 'Build' , value: buildNum) \ ], \ propagate: false echo(result.result) if(result.result != 'SUCCESS') { sh("wget -q -O - https://cforall.uwaterloo.ca/jenkins/job/Cforall_Distribute_Ref/${result.number}/consoleText") error(result.result) } } //=========================================================================================================== //Routine responsible of sending the email notification once the build is completed //=========================================================================================================== //Email notification on a full build failure def promote_email(boolean success) { echo('notifying users') def result = success ? "PROMOTE - SUCCESS" : "PROMOTE - FAILURE" //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line //Configurations for email format def email_subject = "[cforall git][${result}]" def email_body = """

This is an automated email from the Jenkins build machine. It was generated following the result of the C\u2200 nightly build.

Check console output at ${env.BUILD_URL} to view the results.

- Status --------------------------------------------------------------

${result}

- Performance ---------------------------------------------------------

- Logs ----------------------------------------------------------------

""" def email_to = "cforall@lists.uwaterloo.ca" //send email notification emailext body: email_body, subject: email_subject, to: email_to, attachLog: !success }