I'm trying to get full Jenkins consoleText and write it to a file as following:
ByteArrayOutputStream stream = new ByteArrayOutputStream()
currentBuild.rawBuild.getLogText().writeLogTo(0, stream)
writeFile file: "archive/${jobName}-log.txt", text: stream.toString()
However, the contents of the file are getting truncated intermittently.
Jenkins version: 2.361.1
The size of the stream is 32 bytes initially and it is increased if needed. I noticed that the size of the truncated files is 1.2-1.5 MB but the size of the original file is around 3 MB. Could there be some memory issues?
Also, there is no problem with the files that are < 1MB.
CodePudding user response:
If you simply want to get a copy of the console log you can do something like the below in your Pipeline.
sh"""
cp ${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/log archive/${JOB_NAME}-log.txt
"""
CodePudding user response:
sh""" curl ${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/consoleText -o archive/${JOB_NAME}-log.txt """