Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions vars/githubChangeset.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// vars/githubChangeset.groovy
// Iterates over commits since the last build and outputs them
// in the following format via echo:
// - Commit message [author]

def call() {
def changeString = ""
def changeLogSets = currentBuild.changeSets

// Iterate over changes and add them to changeString
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]
changeString += " - ${entry.msg} [${entry.author}]\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timestamp would be nice per https://support.cloudbees.com/hc/en-us/articles/217630098-How-to-access-Changelogs-in-a-Pipeline-Job-

Also, it would be awesome to do this with pure shell, but I guess the hard part is figuring out the last built commit - git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit 68e07c5

}
}

if (!changeString) {
changeString = " - No new changes\n"
}

changeString = "SCM Changes:\n------------------------------------------------------------\n" +
changeString + "-------------------------------------------------------------";
echo changeString
}