使用groovy插件保存ci的状态文件

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

/**
 * @author petert
 * @since  V1.0
 * To save all logs into file if status is not success
 */
def basedir = "D:\\testreport\\report_ci\\"
def result = manager.build.result
def build_number = manager.build.number
def env = manager.build.getEnvironment(manager.listener)
def build_url = env['BUILD_URL']
def build_branch = env['SVN_BRANCH']
def host = env['NODE_NAME']
def svn_rev = env['SVN_REVISION']
def tag = env['BUILD_TAG']
def directory = basedir + tag + result
def dir = new File(directory)
if (!dir.exists()){
	dir.mkdirs()
}
def file2 =  new File(dir,'result.log')
if(manager.build.getResult().equals(hudson.model.Result.SUCCESS)){
	file2.write("BUILD SUCCESSFUL","UTF-8")
}
else{
	def log = manager.build.getLog()
	file2.write(log,'utf-8')
}