我有一个批处理文件可以让我的生活变得轻松。
我想构建一个 Maven 项目,然后将分发从目标文件夹复制到另一个文件夹,然后解压缩它们,然后执行一些复制替换指令。当代码没有问题时,这工作得很好。
如果构建有任何问题并且构建失败,那么我想停止批处理执行。
我无法弄清楚。
::Kill all the java processs
taskkill /f /im "java.exe"
::Take the sprint number form the user
set /p sprintNumber=Enter the sprint number:%=%
:: Navigate to the code path
cd D:\Sprint-%sprintNumber%
call D:
:: Build the code
::@echo ###############BUILDING####################
::call mvn clean install
::cd ..
::Remove the distribution
IF EXIST "D:\Distribution\Sprint-%sprintNumber%\" (
rmdir "D:\Distribution\Sprint-%sprintNumber%\" /s /q
)
::Few more instructions
如果 maven 安装失败,我想停止执行。请提供任何建议以完成此任务。
最佳答案
在构建命令之后的行上添加类似的内容
if errorlevel 1 echo An error occurred & pause & goto :EOF
关于java - maven构建失败时如何停止批处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22140242/