I'd like to archive the build log of every build, e.g. 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. the script can be run from a another job using groovy step or scripptler step.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With