热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Jenkins_MSDeploySample

@ECHOOFFECHO******************************************************************************

@ECHO OFF


ECHO ***************************************************************************************************
ECHO ** Deploy Command For  SoapDataManager.Performance                                     
ECHO ***************************************************************************************************

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::Init environment and check before deployment
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

IF %1]==] GOTO Usage
IF %2]==] GOTO Usage
IF %3]==] GOTO Usage
IF %4]==] GOTO Usage

SET @AppName=SoapDataManager.Performance
SET @VersiOnNumber=%1
SET @PackageName=%@AppName%-%@VersionNumber%.Latest.zip
SET @BuildNumber=%2
SET @IsBackup=%3
SET @TargetEnvirOnment=%4
SET @TargetServer=SZPC668G
SET @SourcePackageRoot=\\10.86.17.1\DeployPackages\GPP\%@AppName%


:: Set variables for beta environment
IF %@TargetEnvironment% EQU Beta (
   SET @TargetRoot=\\%@TargetServer%\D$\WWWRoot\%@AppName%
   SET @TargetBackupRoot=\\%@TargetServer%\D$\Processes\Performance
)

:: Set variables for production environment
IF %@TargetEnvironment% EQU Production (
   SET @TargetRoot=\\%@TargetServer%\D$\WWWRoot\%@AppName%
   SET @TargetBackupRoot=\\%@TargetServer%\D$\Processes\Performance
)

:: Check if deployed package is existed or not
IF NOT EXIST %@SourcePackageRoot%/%@PackageName% (
  ECHO ERROR: ** Could not find deployment package "%@PackageName%"
  GOTO ExitError
)

:: Set variables for 7zip
IF EXIST "C:\Program Files\7-Zip\7z.exe" (
  SET @7ZEXE="C:\Program Files\7-Zip\7z.exe"
) ELSE (
  ECHO ERROR: ** Could not find 7Zip EXE
  GOTO ExitError
)

:: Set msdeploy variables
IF EXIST "C:\Program Files\IIS\Microsoft Web Deploy V2\msdeploy.exe" (
  SET MSDEPLOY_EXE=C:\Program Files\IIS\Microsoft Web Deploy V2\msdeploy.exe
) ELSE (
  ECHO Could not find Microsoft Web Deploy V2 msdeploy.exe
  GOTO ErrorExit
)

ECHO AppName ------------- %@AppName%
ECHO PackageName --------- %@PackageName%
ECHO IsBackup ------------ %@IsBackup%
ECHO TargetEnvironment --- %@TargetEnvironment%
ECHO SourcePackageRoot --- %@SourcePackageRoot%
ECHO TargetRoot ---------- %@TargetRoot%
ECHO TargetServer -------- %@TargetServer%
ECHO TargetBackupRoot ---- %@TargetBackupRoot%

 

ECHO :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ECHO ::::Step 1 -deploy Applications Part
ECHO :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

IF EXIST "%@TargetRoot%" (
   IF %@IsBackup% EQU Y (
      ECHO INFO :## Backup target application - "%@AppName%" ...
      %@7ZEXE% A "%@TargetBackupRoot%\%@AppName%\Backup\%@AppName%-%@VersionNumber%.%@BuildNumber%.zip" "%@TargetRoot%\*" -x!"Backup\*" ) )
IF ERRORLEVEL 1 (
   ECHO ERROR: ** Backup target application - "%@AppName%" failed
   GOTO ExitError )
     
ECHO INFO : ## Deploying "%@AppName%" by msdeploy ...

"%MSDEPLOY_EXE%" ^
    -verb:sync ^
    -source:package="%@SourcePackageRoot%/%@PackageName%" ^
    -dest:cOntentPath=%@TargetRoot%,computerName=%@TargetServer% ^
   
IF ERRORLEVEL 1 (
   ECHO ERROR: ** Deploying "%@TargetAppName%" by msdeploy failed
   GOTO ExitError)


ECHO :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ECHO ::::Step 2 -Deployment finish
ECHO :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

ECHO INFO : ## Deploy "%@AppName%" successfully
EXIT /B 0


:ExitError
ECHO :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ECHO ::::Step 2 -Deployment finish
ECHO :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

ECHO Error : ** Deploy "%@AppName%" failed
EXIT /B 1

:Usage
ECHO Usage: %0 [Team Name]
ECHO Example: %0 GPP

 


推荐阅读
author-avatar
mobiledu2502925163
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有