Sakthisiga
Sakthisiga

Reputation: 93

How to write Jenkins console output to workspace in Jenkins

I have searched over the internet and could not find any option to write the job's console output to a file in workspace. Could you someone please help me out?

Upvotes: 0

Views: 3239

Answers (1)

Daniel Omoto
Daniel Omoto

Reputation: 2491

You can add a groovy system script or groovy post build step to gain access to the console output using manager.build.logFile.text (if post build groovy) or build.logFile.text if groovy system script.

Once you have that, you can write out the string to a file using either the standard File function (if everything is running on Jenkins master) or FilePath (if the job is running on a remote slave).

Please see this answer for an explanation of the FilePath class.

Upvotes: 1

Related Questions