I wrote a batch to check and deploy the rails app from github, the batch file see below. The problem is git.exe fetch origin | find "remote: Counting Objects" always returns errorlevel 1, even when we have new commits. I must terminate the Rails App first, because some files are locked (*.jars) and cause the git pull command to fail.
I search and found below topic, but even using git.exe instead of the git.cmd, the problem still exists.
I try to using a temp file to store git.exe fetch origin result, but if seems this command always print the result to the console.
Also:
git pull | find "Already up-to-date."
if %errorlevel% == 1 (
Works fine
REM @echo off
set path=%path%;C:\Program Files\Git\bin;D:\jruby-1.6.7\bin
set JRUBY_OPTS=--1.9
git.exe fetch origin | find "remote: Counting objects"
if %errorlevel% == 0 taskkill /f /im:jruby.exe
git pull | find "Already up-to-date."
if %errorlevel% == 1 (
REM
start cucumber.bat
REM do something else when update
)
REM RAILS
tasklist | find "jruby.exe"
if %errorlevel%==1 (
echo @rails s > rail.bat
echo @exit >> rail.bat
start cmd /c rail.bat
)
exit