如何从Jenkins获取SVN中已更改文件的列表 [英] How to get the list of changed file in SVN from Jenkins
本文介绍了如何从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.
这篇关于如何从Jenkins获取SVN中已更改文件的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文