jenkins freestyle project write to file current build log
- User
jenkins freestyle project write to file current build log
- Assistant
To write the current build log of a Jenkins freestyle project to a file, you can add a post-build step to execute a shell script that redirects the build log to a file. Here's how you can do it:
-
Open your Jenkins freestyle project.
-
Click on the project's name to open its configuration page.
-
Scroll down to the "Post-build Actions" section.
-
Click on the "Add post-build action" dropdown and select "Execute shell".
-
In the "Command" textarea, enter the following command:
shellcat $JENKINS_HOME/jobs/$JOB_NAME/builds/$BUILD_NUMBER/log > /path/to/save/build.logReplace
/path/to/save/build.logwith the actual path where you want to save the build log file. You can specify a relative path likebuild.logif you want to save it in the project's workspace. -
Save the project configuration.
Now, whenever a build is completed, the build log will be written to the specified file.
-