有人拥有Jenkins Pipeline脚本,可以将自上一次成功构建以来的所有更改填充到变量中吗?我正在使用git和多分支管道作业。
好吧,我设法把一些东西凑在一起。我敢肯定,您可以更好地迭代数组,但这是我现在所拥有的:
node('Android') { passedBuilds = [] lastSuccessfulBuild(passedBuilds, currentBuild); def changeLog = getChangeLog(passedBuilds) echo "changeLog ${changeLog}" } def lastSuccessfulBuild(passedBuilds, build) { if ((build != null) && (build.result != 'SUCCESS')) { passedBuilds.add(build) lastSuccessfulBuild(passedBuilds, build.getPreviousBuild()) } } @NonCPS def getChangeLog(passedBuilds) { def log = "" for (int x = 0; x < passedBuilds.size(); x++) { def currentBuild = passedBuilds[x]; def changeLogSets = currentBuild.rawBuild.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] log += "* ${entry.msg} by ${entry.author} \n" } } } return log; }