简体   繁体   English

存档Jenkins构建日志

[英]Archiving the Jenkins build log

I'd like to archive the build log of every build, eg to a database. 我想将每个构建的构建日志存档,例如归档到数据库。 I know how to archive artifacts, but I don't see anything obvious for the build log. 我知道如何存档工件,但我没有看到任何明显的构建日志。

I guess you need that your job would end before you archive it. 我想你需要在归档之前结束你的工作。 following is a groovy script with different methods to get the console log of a build. 以下是一个groovy脚本,具有不同的方法来获取构建的控制台日志。 the script can be run from a another job using groovy step or scripptler step. 脚本可以使用groovy步骤或scripptler步骤从另一个作业运行。

def jenkins = Jenkins.getInstance()
def job = jenkins.getItem(jobName)
def bld = job.getBuildByNumber(buildNumber)
//use the method that suits you
bld.getLog(100) //number of lines to read
bld.getLogFile()
bld.getLogReader() 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM