- /**
- * 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')
- }
- //该片段来自于http://www.codesnippet.cn/detail/110220148680.html
来源: http://www.codesnippet.cn/detail/110220148680.html