Jenkins的日志更改

Jenkins的日志更改,第1张

Jenkins的日志更改

// This is a deliciously convoluted and fragile hack to force Jenkins to show the
// changes via a Groovy Postbuild script:

// fake a Subversion changelog.xml filechanges = new File(manager.build.getRootDir(), "../../workspace/changes.txt")changelog = new File(manager.build.getRootDir(), "changelog.xml")changelog.withWriter {  out ->out.println("<?xml version="1.0" encoding="UTF-8"?><log><logentry revision=""  + manager.build.number + ""><date>"  + new java.util.Date() + "</date><paths>")message  = ""changes.eachLine {   line ->     if (line.startsWith("./")) line = line.substring(2)     if (!".checksums".equals(line)) {       out.println("<path action="M">" + line + "</path>")       message += line + "n"    }   }  out.println("</paths><msg>" + message + "</msg></logentry></log>")}// get an instance of the SubversionChangeLogParserimport java.net.URL;import java.net.URLClassLoader;baseDir = new File(jenkins.model.Jenkins.getInstance().getRootDir(),  "plugins/subversion/WEB-INF/")urls = new URL[2];urls[0] = new File(baseDir, "classes/").toURI().toURL() urls[1] = new File(baseDir, "lib/svnkit-1.3.4-hudson-2.jar").toURI().toURL() loader = new URLClassLoader(urls,  manager.getClass().getClassLoader())svn = loader.loadClass("hudson.scm.SubversionChangeLogParser").newInstance()// force the current build to take that parser, parse the changelog.xml,// and force it down AbstractBuild's throat, tooscmField = manager.build.getClass().getSuperclass().getSuperclass().getDeclaredField("scm")scmField.setAccessible(true)scmField.set(manager.build, svn)changeSet = svn.parse(manager.build, changelog)changeSetField = manager.build.getClass().getSuperclass().getSuperclass().getDeclaredField("changeSet");changeSetField.setAccessible(true)import java.lang.ref.WeakReference;if (changeSetField.getDeclaringClass().isAssignableFrom(WeakReference.class))  changeSet = new WeakReference(changeSet)changeSetField.set(manager.build, changeSet)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5008177.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-14
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存