def allChangeSetsFromLastSuccessfulBuild() {
def job = Jenkins.instance.getItem("$JOB_NAME")
def lastSuccessBuild = job.lastSuccessfulBuild.number as int
def currentBuildId = "$BUILD_ID" as int
def changeSets = []
for(int i = lastSuccessBuild + 1; i < currentBuildId; i++) {
echo "Getting Change Set for the Build ID : ${i}"
def changeSet = job.getBuildByNumber(i).getChangeSets()
changeSets.addAll(changeSet)
}
changeSets.addAll(currentBuild.changeSets) // Add the current change set
return changeSets
}
1条答案
按热度按时间gcuhipw91#
您可以使用以下脚本获取上次成功生成与当前生成之间的更改集。如果您只想获取上次生成的更改集,则只需在管道中执行
currentBuild.changeSets
即可。