I have a scheduled Jenkins Project to copy 30 files from one path to another overnight. In this project, i run a batch file stored in my desktop.
My use case is i do not want it to exit in case a file is not found. It is expected that sometimes only 25 out of 30 files will be found in the source folder. It should just carry on executing as normal. Now via Jenkins, I would like for it to send me the console log output of the build where the log should hold entries of the files not found.
The contents of the batch are as follows. (In the actual code I have 30, but only 2 files for this example.)
@echo off
rem The * at the end of the destination file is to avoid File/Directory Internal Question.
rem You can do this for each specific file. (Make sure you already have permissions to the path)
echo f | xcopy /f /s "C:\Orig\File1.txt" "C:\tgt\CopFile1.txt*"
echo f | xcopy /f /s "C:\Orig\File2.txt" "C:\tgt\CopFile2txt*"
exit
In my build step, I have selected "Execute Windows batch command", where i mention the path to the batch.
In case the whole build result is a "Failure", I have already enabled the send mail notification using the Extended-Email. Sometimes, 1 or 2 files are not found and as a result displays an "ERROR" in the console output, but the build shows as "Success".
Is it possible to get an email even when build is successful, but console log has "Error"?
Here is the "Default Content" of my Email notification:
<html>
<body>
You are receiving this email, because Build status identified as : <b>$BUILD_STATUS </b>
<br>
Build URL : $BUILD_URL
<br>
<br>
Console Output: -----------------------------------------------<br>
<pre>$BUILD_LOG</pre>
</body>
</html>