From 00add7d4d705ee67362e2582fd632f080e18dec2 Mon Sep 17 00:00:00 2001 From: Craig Vitter Date: Fri, 18 Aug 2017 13:57:49 -0400 Subject: [PATCH] Add githubChangeset, retrieves latest commits for build --- vars/githubChangeset.groovy | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 vars/githubChangeset.groovy diff --git a/vars/githubChangeset.groovy b/vars/githubChangeset.groovy new file mode 100644 index 0000000..365d0cd --- /dev/null +++ b/vars/githubChangeset.groovy @@ -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" + } + } + + if (!changeString) { + changeString = " - No new changes\n" + } + + changeString = "SCM Changes:\n------------------------------------------------------------\n" + + changeString + "-------------------------------------------------------------"; + echo changeString +} \ No newline at end of file