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.