如何从Jenkins获取SVN中已更改文件的列表
问题描述:
在Jenkins中使用SVN时,我需要将已更改文件的列表传递给其他进程。使用上面链接的代码,我得到如下结果:脚本返回:[hudson.scm.SubversionChangeLogSet$Path@6e78d3d7]
Using SVN with Jenkins, I need to pass the list of changed files to some other process. Using the code from the above link, I get a result like this: Script returned: [hudson.scm.SubversionChangeLogSet$Path@6e78d3d7]
我不熟悉Groovy 。有人可以帮我吗?
I am not familiar with Groovy. Can somebody help me out? Thanks.
import hudson.model.*
import hudson.util.*
import hudson.scm.*
import hudson.scm.SubversionChangeLogSet.LogEntry
// work with current build
def build = Thread.currentThread()?.executable
// for testing, use last build or specific build number
//def item = hudson.model.Hudson.instance.getItem("Update_SRC_Branch")
//def build = item.getLastBuild()
//def build = item.getBuildByNumber(35)
// get ChangesSets with all changed items
def changeSet= build.getChangeSet()
List<LogEntry> items = changeSet.getItems()
def affectedFiles = items.collect { it.paths }
def fileNames = affectedFiles.flatten()
new File("/tmp/svn.change.list").withWriter { out ->
fileNames.each {
out.println it
}
}
答
使用currentExecutable代替Build Flow的可执行文件。
Use currentExecutable instead of executable for Build Flows.