Changeset 38bfe32a for Jenkinsfile


Ignore:
Timestamp:
Jun 10, 2016, 3:48:44 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
a63ad80, d14d96a
Parents:
8abfdb4 (diff), afab6dc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Jenkinsfile

    r8abfdb4 r38bfe32a  
    3535}
    3636
     37def push_build() {
     38        //Don't use the build_stage function which outputs the compiler
     39        stage 'Push'
     40
     41                status_prefix = 'Push'
     42
     43                def out_dir = pwd tmp: true
     44                sh "mkdir -p ${out_dir}"
     45
     46                //parse git logs to find what changed
     47                sh "git remote > ${out_dir}/GIT_REMOTE"
     48                git_remote = readFile("${out_dir}/GIT_REMOTE")
     49                remoteDoLangExists = git_remote.contains("DoLang")
     50
     51                if( !remoteDoLangExists ) {
     52                        sh 'git remote add DoLang git@gitlab.do-lang.org:internal/cfa-cc.git'
     53                }
     54
     55                sh "git push DoLang ${gitRefNewValue}:master"
     56}
     57
    3758//===========================================================================================================
    3859// Helper classes/variables/routines to make the status and stage name easier to use
     
    6788def collect_git_info() {
    6889
     90        //create the temporary output directory in case it doesn't already exist
    6991        def out_dir = pwd tmp: true
     92        sh "mkdir -p ${out_dir}"
     93
     94        //parse git logs to find what changed
    7095        gitRefName = env.BRANCH_NAME
    7196        dir("../${gitRefName}@script") {
     
    82107node ('master'){
    83108
     109        boolean doPromoteBuild2DoLang
    84110        def err = null
    85111        def log_needed = false
     
    96122                                collect_git_info()
    97123
     124                                properties ([                                                                   \
     125                                        [$class: 'ParametersDefinitionProperty',                                \
     126                                                parameterDefinitions: [                                         \
     127                                                [$class: 'BooleanParameterDefinition',                          \
     128                                                  defaultValue: false,                                          \
     129                                                  description: 'If true, the build will be promoted to the do-lang git repository (on successful builds only)', \
     130                                                  name: 'promoteBuild2DoLang'                           \
     131                                                ]]                                                                      \
     132                                        ]])
     133
     134                                doPromoteBuild2DoLang = promoteBuild2DoLang == 'true'
     135
     136                                echo "FULL BUILD = ${doPromoteBuild2DoLang}"
     137
    98138                                //Compile using gcc-4.9
    99139                                currentCC = new CC_Desc('gcc-4.9', 'g++-4.9', 'gcc-4.9')
     
    108148                                cfa_build()
    109149
     150                                if( doPromoteBuild2DoLang ) {
     151                                        push_build()
     152                                }
    110153                        }
    111154                }
     
    127170        finally {
    128171                //Send email with final results
    129                 email(currentBuild.result, log_needed)
     172                notify_result(doPromoteBuild2DoLang, err, currentBuild.result, log_needed)
    130173
    131174                /* Must re-throw exception to propagate error */
     
    139182//Routine responsible of sending the email notification once the build is completed
    140183//===========================================================================================================
     184def notify_result(boolean promote, Exception err, String status, boolean log) {
     185        if(promote)     {
     186                if( err ) {
     187                        promote_email(status)
     188                }
     189        }
     190        else {
     191                email(status, log)
     192        }
     193}
     194
     195//Email notification on a full build failure
     196def promote_email(String status) {
     197        //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
     198        //Configurations for email format
     199        def email_subject = "[cforall git][PROMOTE - FAILURE]"
     200        def email_body = """This is an automated email from the Jenkins build machine. It was
     201generated because of a git hooks/post-receive script following
     202a ref change was pushed to the repository containing
     203the project "UNNAMED PROJECT".
     204
     205Check console output at ${env.BUILD_URL} to view the results.
     206
     207- Status --------------------------------------------------------------
     208
     209PROMOTE FAILURE - ${status}
     210"""
     211
     212        def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com"
     213
     214        //send email notification
     215        emailext body: email_body, subject: email_subject, to: email_to, attachLog: true
     216}
     217
     218//Standard build email notification
    141219def email(String status, boolean log) {
    142220        //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
     
    157235
    158236The branch ${env.BRANCH_NAME} has been updated.
    159         via  ${gitRefOldValue} (commit)
    160         from  ${gitRefNewValue} (commit)
     237  via  ${gitRefOldValue} (commit)
     238  from  ${gitRefNewValue} (commit)
    161239
    162240Check console output at ${env.BUILD_URL} to view the results.
Note: See TracChangeset for help on using the changeset viewer.