我安装了Groovy插件,配置了Groovy语言,并创建了一个脚本,然后将其作为“系统Groovy脚本”执行。脚本看起来像:
import java.lang.ProcessBuilder.Redirectimport hudson.model.*import hudson.util.*import hudson.scm.*import hudson.scm.SubversionChangeLogSet.LogEntry// uncomment one of the following def build = ... lines// work with current builddef 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 itemsdef changeSet= build.getChangeSet()List<LogEntry> items = changeSet.getItems()def affectedFiles = items.collect { it.paths }// get filtered file names (only fmb) without pathdef fileNames = affectedFiles.flatten().findResults { if (it.path.substring(it.path.lastIndexOf(".") + 1) != "fmb") return null it.path.substring(it.path.lastIndexOf("/") + 1)}.sort().unique()// setup log filesdef stdOutFile = "${build.rootDir}\stdout.txt"def stdErrFile = "${build.rootDir}\stderr.txt"// now execute the external transformingfileNames.each { def params = [...] def processBuilder = new ProcessBuilder(params) // redirect stdout and stderr to log files processBuilder.redirectOutput(new File(stdOutFile)) processBuilder.redirectError(new File(stdErrFile)) def process = processBuilder.start() process.waitFor() // print log files println new File(stdOutFile).readLines() System.err.println new File(stdErrFile).readLines()}之后,我在命令行中使用“ svn commit”来提交更新的文件。



