retry.cmd 607 B

123456789101112131415161718192021
  1. @echo off
  2. rem Source: https://github.com/appveyor/ci/blob/master/scripts/appveyor-retry.cmd
  3. rem initiate the retry number
  4. set retryNumber=0
  5. set maxRetries=3
  6. :RUN
  7. %*
  8. set LastErrorLevel=%ERRORLEVEL%
  9. IF %LastErrorLevel% == 0 GOTO :EOF
  10. set /a retryNumber=%retryNumber%+1
  11. IF %reTryNumber% == %maxRetries% (GOTO :FAILED)
  12. :RETRY
  13. set /a retryNumberDisp=%retryNumber%+1
  14. @echo Command "%*" failed with exit code %LastErrorLevel%. Retrying %retryNumberDisp% of %maxRetries%
  15. GOTO :RUN
  16. : FAILED
  17. @echo Sorry, we tried running command for %maxRetries% times and all attempts were unsuccessful!
  18. EXIT /B %LastErrorLevel%