From time to time I need to deploy a new web application to a server. There are many ways to do so, but I found this small Windows batch script mighty useful.
- stops the application server service
- copies the files from the directory
./latest
to the proper destination directory
- starts the application server service again
- renames the directory
./latest
with the current date and time (in case you have to rollback)
@echo off
echo Stopping "service x"...
sc \\localhost stop "service x"
echo Deploying files...
xcopy ".\latest\*.*" "destination_dir" /Y /S
echo Restarting "service x"...
sc \\localhost start "schd service"
set Filename=%Date:~-4,4%%Date:~-7,2%%Date:~-10,2%_%Time:~0,2%%Time:~3,2%_application_name
echo Renaming "latest" folder to "%Filename%"...
rename latest %Filename%
pause
Nessun commento:
Posta un commento