bat脚本实现Linux set -e 功能

 

在一个发布脚本中,进行realse操作可能需要如下几个步骤:

 

1. 调用build工具进行build

2. 使用SSH工具上传build出的jar包

3. 使用SSH工具向远程主机发布重启服务的命令

 

上述任何环节出错,则后续动作再执行已无意义,所以整个脚本应该停止执行,这种处理可以使用以下命令方式:

复制代码
call 第三方脚本或程序1

if "%errorlevel%"=="1" goto :end

call 第三方脚本或程序2

if "%errorlevel%"=="1" goto :end
复制代码

 

示例代码

复制代码
@echo off

set profile=%1

if "%2"=="release" goto release

rem #######################################################################################

:release

echo.
echo ***************************************************************************************
echo BUILD ALL MODULES...
echo ***************************************************************************************

call mvn install -DskipTests=true -P%profile%
if "%errorlevel%"=="1" goto :releasefailed

echo.
echo ***************************************************************************************
echo DEPLOY CORE MODULE...
echo ***************************************************************************************

call its-core\target\classes\core-dev-tool.bat deploy
if "%errorlevel%"=="1" goto :releasefailed

echo.
echo ***************************************************************************************
echo DEPLOY CLIENT MODULE...
echo ***************************************************************************************

call its-client\target\classes\client-dev-tool.bat deploy
if "%errorlevel%"=="1" goto :releasefailed

echo.
echo ***************************************************************************************
echo DEPLOY SERVER MODULE...
echo ***************************************************************************************

call its-server\target\classes\server-dev-tool.bat deploy
if "%errorlevel%"=="1" goto :releasefailed

echo.
echo ***************************************************************************************
echo DEPLOY SDK MODULE...
echo ***************************************************************************************

call its-sdk\target\classes\sdk-dev-tool.bat deploy
if "%errorlevel%"=="1" goto :releasefailed

echo.
echo ***************************************************************************************
echo RESTART HBASE ...
echo ***************************************************************************************

call its-server\target\classes\server-dev-tool.bat restart-hbase
if "%errorlevel%"=="1" goto :releasefailed
goto releasesuccess

rem #######################################################################################

:releasesuccess
echo.
echo.
echo ***************************************************************************************
echo RELEASE SUCCESS!!
echo ***************************************************************************************
goto end

:releasefailed
echo.
echo.
echo ***************************************************************************************
echo RELEASE FAILED!!
echo ***************************************************************************************
goto end

:end
复制代码

 

https://www.cnblogs.com/zhangjianbin/p/6286730.html

posted @   ascertain  阅读(428)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示