Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Jenkinsfile

    rab60d6d rb67dc146  
    6464}
    6565
    66 //Helper routine to collect information about the git history
    67 def collect_git_info() {
    68 
    69         def out_dir = pwd tmp: true
    70         gitRefName = env.BRANCH_NAME
    71         dir("../${gitRefName}@script") {
    72                 sh "git reflog > ${out_dir}/GIT_COMMIT"
    73         }
    74         git_reflog = readFile("${out_dir}/GIT_COMMIT")
    75         gitRefOldValue = (git_reflog =~ /moving from (.+) to (.+)/)[0][1]
    76         gitRefNewValue = (git_reflog =~ /moving from (.+) to (.+)/)[0][2]
    77 }
    78 
    7966//===========================================================================================================
    8067// Main loop of the compilation
     
    8572        def log_needed = false
    8673        currentBuild.result = "SUCCESS"
    87         status_prefix = ''
     74
     75        //Properties sent by the git-hooks (ref name, latest commit hash, previous commit hash)
     76        properties( [[$class: 'ParametersDefinitionProperty', parameterDefinitions: \
     77                        [[$class: 'StringParameterDefinition', name: 'GitRefName',     defaultValue: 'master', description: 'name of the ref that changed' ], \
     78                         [$class: 'StringParameterDefinition', name: 'GitRefNewValue', defaultValue: 'HEAD',   description: 'new commit of the reference' ],  \
     79                         [$class: 'StringParameterDefinition', name: 'GitRefOldValue', defaultValue: 'HEAD~1', description: 'old commit of the reference']]   \
     80                ]] )
    8881
    8982        try {
     83                echo "Properties-start"
     84                echo "ref name      : ${GitRefName}"
     85                echo "ref new value : ${GitRefNewValue}"
     86                echo "ref old value : ${GitRefOldValue}"
     87                echo "Properties-stop"
     88
    9089                //Prevent the build from exceeding 30 minutes
    9190                timeout(30) {
     
    9392                        //Wrap build to add timestamp to command line
    9493                        wrap([$class: 'TimestamperBuildWrapper']) {
    95 
    96                                 collect_git_info()
    9794
    9895                                //Compile using gcc-4.9
     
    110107                        }
    111108                }
     109
    112110        }
    113111
     
    144142        def project_name = (env.JOB_NAME =~ /(.+)\/.+/)[0][1].toLowerCase()
    145143
    146         sh "git rev-list --format=short ${gitRefOldValue}...${gitRefNewValue} > GIT_LOG"
    147         def gitLog = readFile('GIT_LOG')
    148 
    149         sh "git diff --stat ${gitRefNewValue} ${gitRefOldValue} > GIT_DIFF"
    150         def gitDiff = readFile('GIT_DIFF')
    151 
    152144        def email_subject = "[${project_name} git][BUILD# ${env.BUILD_NUMBER} - ${status}] - branch ${env.BRANCH_NAME}"
    153145        def email_body = """This is an automated email from the Jenkins build machine. It was
     
    157149
    158150The branch ${env.BRANCH_NAME} has been updated.
    159          via  ${gitRefOldValue} (commit)
    160         from  ${gitRefNewValue} (commit)
    161151
    162 Check console output at ${env.BUILD_URL} to view the results.
     152Check console output at ${env.BUILD_URL} to view the results."""
    163153
    164 - Status --------------------------------------------------------------
    165 
    166 BUILD# ${env.BUILD_NUMBER} - ${status}
    167 
    168 - Log -----------------------------------------------------------------
    169 ${gitLog}
    170 -----------------------------------------------------------------------
    171 Summary of changes:
    172 ${gitDiff}
    173 """
    174 
     154        // def config = new File('/u/cforall/software/cfa/cfa-cc/config').text
     155        // def email_to = (config =~ /mailinglist ?= ?(.+)/)[0][1]
    175156        def email_to = "pabuhr@uwaterloo.ca, rschlunt@uwaterloo.ca, a3moss@uwaterloo.ca, tdelisle@uwaterloo.ca, brice.dobry@huawei.com"
    176157
Note: See TracChangeset for help on using the changeset viewer.