Skip to content

Instantly share code, notes, and snippets.

@emexelem
Created January 20, 2020 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emexelem/f84aabb2b4e9bbe2f949e045917d210b to your computer and use it in GitHub Desktop.
Save emexelem/f84aabb2b4e9bbe2f949e045917d210b to your computer and use it in GitHub Desktop.
node('master') {
checkout(scm: [$class: 'GitSCM',
branches: [[name: "*/develop"]],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'repo1']],
userRemoteConfigs: [[credentialsId: 'bitbucket.jenkins',
url: 'urlToRepo.git']]],
changelog: true, poll: true)
showChangeLogs()
//currentBuild.result = 'FAILURE'
emailext(
subject: 'Deployment',
body: '${SCRIPT, template="groovy-html.template"}',
to: 'email@address.com')
}
@NonCPS
def showChangeLogs() {
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}"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment