Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Jenkinsfile

    rb94206b rc0588909  
    22
    33//===========================================================================================================
    4 // Main compilation routines
     4// Main compilation routine
    55//===========================================================================================================
    66//Compilation script is done here but environnement set-up and error handling is done in main loop
     
    8383}
    8484
     85def push_build() {
     86        //Don't use the build_stage function which outputs the compiler
     87        stage 'Push'
     88
     89                status_prefix = 'Push'
     90
     91                def out_dir = pwd tmp: true
     92                sh "mkdir -p ${out_dir}"
     93
     94                //parse git logs to find what changed
     95                sh "git remote > ${out_dir}/GIT_REMOTE"
     96                git_remote = readFile("${out_dir}/GIT_REMOTE")
     97                remoteDoLangExists = git_remote.contains("DoLang")
     98
     99                if( !remoteDoLangExists ) {
     100                        sh 'git remote add DoLang git@gitlab.do-lang.org:internal/cfa-cc.git'
     101                }
     102
     103                sh "git push DoLang ${gitRefNewValue}:master"
     104}
     105
    85106//===========================================================================================================
    86107// Helper classes/variables/routines to make the status and stage name easier to use
     
    134155node ('master'){
    135156
    136         boolean bIsFullBuild
     157        boolean doPromoteBuild2DoLang
    137158        def err = null
    138159        def log_needed = false
     
    155176                                                  defaultValue: false,                                          \
    156177                                                  description: 'If true, the build will be promoted to the do-lang git repository (on successful builds only)', \
    157                                                   name: 'isFullBuild'                                   \
     178                                                  name: 'promoteBuild2DoLang'                                   \
    158179                                                ],                                                              \
    159180                                                [$class: 'ChoiceParameterDefinition',                           \
     
    165186                                        ]])
    166187
    167                                 bIsFullBuild = isFullBuild == 'true'
     188                                doPromoteBuild2DoLang = promoteBuild2DoLang == 'true'
    168189                                architectureFlag = buildArchitecture == '64-bit' ? '-m64' : (buildArchitecture == '32-bit' ? '-m32' : 'ERROR')
    169190
    170                                 echo "FULL BUILD = ${isFullBuild}\nArchitecture = ${buildArchitecture} (flag ${architectureFlag})"
     191                                echo "FULL BUILD = ${doPromoteBuild2DoLang}\nArchitecture = ${buildArchitecture} (flag ${architectureFlag})"
    171192
    172193                                //Compile using gcc-4.9
    173194                                currentCC = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9')
    174                                 cfa_build(bIsFullBuild, architectureFlag)
     195                                cfa_build(doPromoteBuild2DoLang, architectureFlag)
    175196
    176197                                //Compile latex documentation
    177198                                doc_build()
    178199
    179                                 if( bIsFullBuild ) {
     200                                if( doPromoteBuild2DoLang ) {
    180201                                        //Compile using gcc-5
    181202                                        currentCC = new CC_Desc('gcc-5', 'g++-5', 'gcc-5')
     
    185206                                        currentCC = new CC_Desc('gcc-6', 'g++-6', 'gcc-6')
    186207                                        cfa_build(true, architectureFlag)
     208
     209                                        //Push latest changes to do-lang repo
     210                                        push_build()
    187211                                }
    188212                        }
     
    204228
    205229        finally {
    206                 echo 'Build Completed'
    207 
    208                 //Send email with final results if this is not a full build
    209                 if( !bIsFullBuild ) {
    210                         echo 'Notifying users of result'
    211                         email(currentBuild.result, log_needed)
    212                 }
     230                //Send email with final results
     231                notify_result(doPromoteBuild2DoLang, err, currentBuild.result, log_needed)
    213232
    214233                /* Must re-throw exception to propagate error */
     
    222241//Routine responsible of sending the email notification once the build is completed
    223242//===========================================================================================================
     243def notify_result(boolean promote, Exception err, String status, boolean log) {
     244        echo 'Build completed, sending result notification'
     245        if(promote)     {
     246                if( err ) {
     247                        promote_email(status)
     248                }
     249        }
     250        else {
     251                email(status, log)
     252        }
     253}
     254
     255//Email notification on a full build failure
     256def promote_email(String status) {
     257        //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
     258        //Configurations for email format
     259        def email_subject = "[cforall git][PROMOTE - FAILURE]"
     260        def email_body = """This is an automated email from the Jenkins build machine. It was
     261generated because of a git hooks/post-receive script following
     262a ref change was pushed to the repository containing
     263the project "UNNAMED PROJECT".
     264
     265Check console output at ${env.BUILD_URL} to view the results.
     266
     267- Status --------------------------------------------------------------
     268
     269PROMOTE FAILURE - ${status}
     270"""
     271
     272        def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com"
     273
     274        //send email notification
     275        emailext body: email_body, subject: email_subject, to: email_to, attachLog: true
     276}
     277
    224278//Standard build email notification
    225279def email(String status, boolean log) {
Note: See TracChangeset for help on using the changeset viewer.