Saving job log as text file?

6,277 views
Skip to first unread message

karlis purens

unread,
Apr 25, 2016, 6:43:21 AM4/25/16
to Jenkins Users
Hello,

How can Jenkins job console be saved as a text file on slave machine?

I am working with a project that generates long and complex console logs - that are later analyzed for determining potential problems.

At the moment after each build i have to login to jenkins and manually copy the console to a text file, which is then analyzed. (you can see how cumbersome that is)

I have tried looking for console output in the job workspace of slave machine, but no files are generated in the workspace.
I have also tried saving the file from console by downloading the contents of job console url, but haven't found any suitable commands.

Slave machine is running on Windows 7
Using wget is not possible in this case because of restricted access.

Any help would be greatly appreciated.

karlis purens

unread,
Apr 28, 2016, 7:56:38 AM4/28/16
to Jenkins Users
For future reference if anyone else stumbles upon a similar problem:

I couldn't find a way to download console logs.
But it's possible to open console logs on the slave machine using %BUILD_URL%consoleText

So i executed a post-build-task cmd: start "" "%BUILD_URL%consoleText"
This opens job console plaintext in your default broswer (chrome in my case)

And it just so happens that chrome has an excellent extension called Tampermonkey - which can execute any javascript code on webpage startup.
So i made a bunch of if statements using tampermonkey's javascript which are executed when the console url is opened.
(Beware - there are problems with closing the tab, if you want to close the tab after you're done, put it inside a separate tampermonkey script)

And there it is - fully automated console text parser.

alex....@gmail.com

unread,
Jan 11, 2019, 3:33:33 PM1/11/19
to Jenkins Users
0

Log location:

${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/log

MAC: Get log as a text and save to workspace:

cat ${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/log >> log.txt


WINDOWS: Get log as a text and save to workspace:

type ${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/log > log.txt


Reply all
Reply to author
Forward
0 new messages