How can i get the Jenkins console output in a text file? I want to share it with someone, is there any way to do it?
Asked
Active
Viewed 1e+01k times
4 Answers
46
if you want just access the log and download it as a txt file to your workspace from the job's URL:
${BUILD_URL}/consoleText
On Linux, you can use wget to download it to your workspace
wget ${BUILD_URL}/consoleText
The actual log file on the file system is in the Master machine. You can find it under:
$JENKINS_HOME/jobs/$JOB_NAME/builds/lastSuccessfulBuild/log
Subhash
- 1,586
- 11
- 18
4
For Windows you could use curl in a powershell prompt:
curl ${BUILD_URL}\consoleText -OutFile C:\SomeLocation\SomeFile.txt
For MacOS:
curl ${BUILD_URL}/consoleText -o /SomeLocation/SomeFile.txt
Yeongjun Kim
- 103
- 2
Will Brode
- 141
- 4
2
To get the Jenkins console log without curl or wget:
writeFile file: "jenkins_console_output.txt", text: currentBuild.rawBuild.logFile.text
sh 'sed -ri "s/\\x1b\\[8m.*?\\x1b\\[0m//g" jenkins_console_output.txt'
Explanation:
currentBuild.rawBuild.logFile.textwill return annotated log.\x1b\[8m.*?\x1b\[0mis a regex expression to match AnsiColorersed -riuse regexp-extended and in-place to update the file
Peter Turner
- 1,482
- 4
- 18
- 39
yoann
- 21
- 1
0
Open {job-url-with-build}/consoleText, and while it's loading in browser, hit Ctrl+S, and save it in local disk.
Shashi Ranjan
- 1
- 1