Index: Jenkinsfile
===================================================================
--- Jenkinsfile	(revision e57ebb5a4af112da05a52913321e1aee08879091)
+++ Jenkinsfile	(revision a336d46f0710a49accb97983fdb83b2a59eb6c3c)
@@ -64,5 +64,4 @@
 		//Send email with final results if this is not a full build
 		if( Settings && !Settings.Silent ) {
-			echo 'Notifying users of result'
 			email(log_needed, Settings.IsSandbox)
 		}
@@ -93,40 +92,9 @@
 	build_stage('Checkout') {
 		//checkout the source code and clean the repo
-		checkout scm
-
-		def changeLogSets = currentBuild.changeSets
-		for (int i = 0; i < changeLogSets.size(); i++) {
-			def entries = changeLogSets[i].items
-			for (int j = 0; j < entries.length; j++) {
-				def entry = entries[j]
-				echo "${entry.commitId} by ${entry.author} on ${new Date(entry.timestamp)}: ${entry.msg}"
-				def files = new ArrayList(entry.affectedFiles)
-				for (int k = 0; k < files.size(); k++) {
-					def file = files[k]
-					echo "  ${file.editType.name} ${file.path}"
-				}
-			}
-		}
-
-		echo """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.
-
-- Status --------------------------------------------------------------
-
-BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}
-
-- Log -----------------------------------------------------------------
-
------------------------------------------------------------------------
-Summary of changes:
-
-"""
+		final scmVars = checkout scm
+		Settings.GitNewRef = scmVars.GIT_COMMIT
+		Settings.GitOldRef = scmVars.GIT_PREVIOUS_COMMIT
+
+		echo GitLogMessage()
 	}
 }
@@ -210,5 +178,5 @@
 //Routine responsible of sending the email notification once the build is completed
 //===========================================================================================================
-def gitBranchUpdate(String gitRefOldValue, String gitRefNewValue) {
+def gitUpdate(String gitRefOldValue, String gitRefNewValue) {
 	def update = ""
 	sh "git rev-list ${gitRefOldValue}..${gitRefNewValue} > GIT_LOG";
@@ -225,7 +193,35 @@
 	update += "      from  ${rev} (${type})\n"
 	return update
-
-	def output=readFile('result').trim()
-	echo "output=$output";
+}
+
+def gitLog(String gitRefOldValue, String gitRefNewValue) {
+	sh "git rev-list --format=short ${oldRef}...${newRef} > ${BuildDir}/GIT_LOG"
+	return readFile("${BuildDir}/GIT_LOG")
+}
+
+def gitDiff(String gitRefOldValue, String gitRefNewValue) {
+	sh "git diff --stat ${newRef} ${oldRef} > ${BuildDir}/GIT_DIFF"
+	return readFile("${BuildDir}/GIT_DIFF")
+}
+
+def GitLogMessage() {
+	if (!Settings || !Settings.GitOldRef || !Settings.GitNewRef) return "\nERROR retrieveing git information!\n"
+
+	return """
+The branch ${env.BRANCH_NAME} has been updated.
+${gitUpdate(Settings.GitOldRef, Settings.GitNewRef)}
+
+Check console output at ${env.BUILD_URL} to view the results.
+
+- Status --------------------------------------------------------------
+
+BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}
+
+- Log -----------------------------------------------------------------
+${gitLog(Settings.GitOldRef, Settings.GitNewRef)}
+-----------------------------------------------------------------------
+Summary of changes:
+${gitDiff(Settings.GitOldRef, Settings.GitNewRef)}
+"""
 }
 
@@ -234,47 +230,12 @@
 	//Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
 	//Configurations for email format
+	echo 'Notifying users of result'
+
 	def project_name = (env.JOB_NAME =~ /(.+)\/.+/)[0][1].toLowerCase()
-
-	def gitLog = 'Error retrieving git logs'
-	def gitDiff = 'Error retrieving git diff'
-	def gitUpdate = 'Error retrieving update'
-
-	try {
-		final scmVars = checkout(scm)
-
-		gitUpdate = gitBranchUpdate(scmVars.GIT_PREVIOUS_COMMIT, scmVars.GIT_COMMIT)
-
-		sh "git rev-list --format=short ${scmVars.GIT_PREVIOUS_COMMIT}...${scmVars.GIT_COMMIT} > ${BuildDir}/GIT_LOG"
-		gitLog = readFile("${BuildDir}/GIT_LOG")
-
-		sh "git diff --stat ${scmVars.GIT_COMMIT} ${scmVars.GIT_PREVIOUS_COMMIT} > ${BuildDir}/GIT_DIFF"
-		gitDiff = readFile("${BuildDir}/GIT_DIFF")
-	}
-	catch (Exception error) {
-		echo error.toString()
-		echo error.getMessage()
-	}
-
 	def email_subject = "[${project_name} git][BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}] - 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.
-${gitUpdate}
-
-Check console output at ${env.BUILD_URL} to view the results.
-
-- Status --------------------------------------------------------------
-
-BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}
-
-- Log -----------------------------------------------------------------
-${gitLog}
------------------------------------------------------------------------
-Summary of changes:
-${gitDiff}
-"""
+a ref change which was pushed to the Cforall repository.
+""" + GitLogMessage()
 
 	def email_to = "cforall@lists.uwaterloo.ca"
@@ -329,4 +290,7 @@
 	public final String DescShort
 
+	public String GitNewRef
+	public String GitOldRef
+
 	BuildSettings(java.util.Collections$UnmodifiableMap param, String branch) {
 		switch( param.Compiler ) {
@@ -377,4 +341,7 @@
 Silent                  : ${ this.Silent.toString() }
 """
+
+		this.GitNewRef = ''
+		this.GitOldRef = ''
 	}
 }
