Try to search your question here, if you can't find : Ask Any Question Now ?

Why does batch file execution fail ONLY IN Jenkins with error message that compressed .rar file doesn't exist?

HomeCategory: stackoverflowWhy does batch file execution fail ONLY IN Jenkins with error message that compressed .rar file doesn't exist?
Avatarbhawya asked 5 days ago

I’ve created simple batch file, that backs up my Jenkins directory. Everything is working without a hitch, but once I set up my build with “Execute Windows batch command” the batch file will fail saying “File already exist, or couldn’t be found (loose translation from German). However, running the script locally with user-interaction is working just fine!

@echo off &color 1f && Title [Backup for Jenkins]

REM Path for Winrar
set path="C:Program FilesWinRAR";%path%

REM German Date-Format
set gerDate=%date:~0,2%-%date:~3,2%-%date:~6,4%

REM Winrar Backup
REM Base-Folder skipped
rar a -u -ep1 -r -agHH-MM -xC:[Path for 1st skipped folder] -xC:[Path for 2nd skipped folder] Jenkins_%gerDate%_.zip C:[Path to compress all the following files]*.*
color 2f & Title [Backup successful]

echo.
echo Move into different folder
echo.
move C:[Path to the generated .zip file]Jenkins*.zip C:[Path to destination folder - network drive]
echo.
echo Backup completed on%Date% %Time% 
echo.
pause

I’ve noticed that my script is being temporary stored in C:Users[USER]AppDataLocalTemp and since the script has to move the compressed .rar with cmd’s command “move” into different folder, it might be causing my problems… Either way, my .rar is not generated even within Temp folder, so that might not be the case as well.

1 Answers
Best Answer
AvatarArben answered 5 days ago
Your Answer

19 + 15 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com