Changeset a336d46 for Jenkinsfile
- Timestamp:
- Aug 17, 2018, 3:57:44 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 7efec15
- Parents:
- e57ebb5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified Jenkinsfile ¶
re57ebb5 ra336d46 64 64 //Send email with final results if this is not a full build 65 65 if( Settings && !Settings.Silent ) { 66 echo 'Notifying users of result'67 66 email(log_needed, Settings.IsSandbox) 68 67 } … … 93 92 build_stage('Checkout') { 94 93 //checkout the source code and clean the repo 95 checkout scm 96 97 def changeLogSets = currentBuild.changeSets 98 for (int i = 0; i < changeLogSets.size(); i++) { 99 def entries = changeLogSets[i].items 100 for (int j = 0; j < entries.length; j++) { 101 def entry = entries[j] 102 echo "${entry.commitId} by ${entry.author} on ${new Date(entry.timestamp)}: ${entry.msg}" 103 def files = new ArrayList(entry.affectedFiles) 104 for (int k = 0; k < files.size(); k++) { 105 def file = files[k] 106 echo " ${file.editType.name} ${file.path}" 107 } 108 } 109 } 110 111 echo """This is an automated email from the Jenkins build machine. It was 112 generated because of a git hooks/post-receive script following 113 a ref change was pushed to the repository containing 114 the project "UNNAMED PROJECT". 115 116 The branch ${env.BRANCH_NAME} has been updated. 117 118 119 Check console output at ${env.BUILD_URL} to view the results. 120 121 - Status -------------------------------------------------------------- 122 123 BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result} 124 125 - Log ----------------------------------------------------------------- 126 127 ----------------------------------------------------------------------- 128 Summary of changes: 129 130 """ 94 final scmVars = checkout scm 95 Settings.GitNewRef = scmVars.GIT_COMMIT 96 Settings.GitOldRef = scmVars.GIT_PREVIOUS_COMMIT 97 98 echo GitLogMessage() 131 99 } 132 100 } … … 210 178 //Routine responsible of sending the email notification once the build is completed 211 179 //=========================================================================================================== 212 def git BranchUpdate(String gitRefOldValue, String gitRefNewValue) {180 def gitUpdate(String gitRefOldValue, String gitRefNewValue) { 213 181 def update = "" 214 182 sh "git rev-list ${gitRefOldValue}..${gitRefNewValue} > GIT_LOG"; … … 225 193 update += " from ${rev} (${type})\n" 226 194 return update 227 228 def output=readFile('result').trim() 229 echo "output=$output"; 195 } 196 197 def gitLog(String gitRefOldValue, String gitRefNewValue) { 198 sh "git rev-list --format=short ${oldRef}...${newRef} > ${BuildDir}/GIT_LOG" 199 return readFile("${BuildDir}/GIT_LOG") 200 } 201 202 def gitDiff(String gitRefOldValue, String gitRefNewValue) { 203 sh "git diff --stat ${newRef} ${oldRef} > ${BuildDir}/GIT_DIFF" 204 return readFile("${BuildDir}/GIT_DIFF") 205 } 206 207 def GitLogMessage() { 208 if (!Settings || !Settings.GitOldRef || !Settings.GitNewRef) return "\nERROR retrieveing git information!\n" 209 210 return """ 211 The branch ${env.BRANCH_NAME} has been updated. 212 ${gitUpdate(Settings.GitOldRef, Settings.GitNewRef)} 213 214 Check console output at ${env.BUILD_URL} to view the results. 215 216 - Status -------------------------------------------------------------- 217 218 BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result} 219 220 - Log ----------------------------------------------------------------- 221 ${gitLog(Settings.GitOldRef, Settings.GitNewRef)} 222 ----------------------------------------------------------------------- 223 Summary of changes: 224 ${gitDiff(Settings.GitOldRef, Settings.GitNewRef)} 225 """ 230 226 } 231 227 … … 234 230 //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line 235 231 //Configurations for email format 232 echo 'Notifying users of result' 233 236 234 def project_name = (env.JOB_NAME =~ /(.+)\/.+/)[0][1].toLowerCase() 237 238 def gitLog = 'Error retrieving git logs'239 def gitDiff = 'Error retrieving git diff'240 def gitUpdate = 'Error retrieving update'241 242 try {243 final scmVars = checkout(scm)244 245 gitUpdate = gitBranchUpdate(scmVars.GIT_PREVIOUS_COMMIT, scmVars.GIT_COMMIT)246 247 sh "git rev-list --format=short ${scmVars.GIT_PREVIOUS_COMMIT}...${scmVars.GIT_COMMIT} > ${BuildDir}/GIT_LOG"248 gitLog = readFile("${BuildDir}/GIT_LOG")249 250 sh "git diff --stat ${scmVars.GIT_COMMIT} ${scmVars.GIT_PREVIOUS_COMMIT} > ${BuildDir}/GIT_DIFF"251 gitDiff = readFile("${BuildDir}/GIT_DIFF")252 }253 catch (Exception error) {254 echo error.toString()255 echo error.getMessage()256 }257 258 235 def email_subject = "[${project_name} git][BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}] - branch ${env.BRANCH_NAME}" 259 236 def email_body = """This is an automated email from the Jenkins build machine. It was 260 237 generated because of a git hooks/post-receive script following 261 a ref change was pushed to the repository containing 262 the project "UNNAMED PROJECT". 263 264 The branch ${env.BRANCH_NAME} has been updated. 265 ${gitUpdate} 266 267 Check console output at ${env.BUILD_URL} to view the results. 268 269 - Status -------------------------------------------------------------- 270 271 BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result} 272 273 - Log ----------------------------------------------------------------- 274 ${gitLog} 275 ----------------------------------------------------------------------- 276 Summary of changes: 277 ${gitDiff} 278 """ 238 a ref change which was pushed to the Cforall repository. 239 """ + GitLogMessage() 279 240 280 241 def email_to = "cforall@lists.uwaterloo.ca" … … 329 290 public final String DescShort 330 291 292 public String GitNewRef 293 public String GitOldRef 294 331 295 BuildSettings(java.util.Collections$UnmodifiableMap param, String branch) { 332 296 switch( param.Compiler ) { … … 377 341 Silent : ${ this.Silent.toString() } 378 342 """ 343 344 this.GitNewRef = '' 345 this.GitOldRef = '' 379 346 } 380 347 }
Note: See TracChangeset
for help on using the changeset viewer.