我的jenkins自动部署方案演进史
项目要实施持续集成,一天可能发生几次集成,不可能靠人工一遍遍地操作,自然使用自动部署。我们选择的jenkins。一、使用插件最开始我试着采用以下两个插件:1、Deploy to container PluginThis plugin allows you to deploy a war to a container after a successful buil
@echo off
set jboss_path=E:\gxpt-jboss-1.0
set project_name=%WORKSPACE%\target\%JOB_NAME%-%1.%2
if exist %project_name% (
echo %BUILD_ID% -- 正在部署%project_name%
copy /y %project_name% %jboss_path%\server\default\deploy\
) else (
echo %BUILD_ID% -- 未找到%project_name%
)
@echo off & setlocal EnableDelayedExpansion
set jboss_path=E:\gxpt-jboss-1.0
set project_sn=%1
set project_default=%jboss_path%\server\default_%project_sn%\deploy\
set project_home=%JENKINS_HOME%
set project_tmp=%project_home%\tmp_%project_sn%
set workspace=%project_home%\workspace
if not exist %project_tmp% md %project_tmp%
echo [%BUILD_ID%] 正在检索所有jar包和war包到%project_tmp%临时目录
for /r "%workspace%" %%i in (gxpt_common_*.jar) do (
echo 正在复制%%i到%project_tmp%\
copy /y "%%i" %project_tmp%\
)
for /r "%workspace%" %%i in (gxpt_*_%project_sn%*.?ar) do (
echo 正在复制%%i到%project_tmp%\
copy /y "%%i" %project_tmp%\
)
echo [%BUILD_ID%] 完成复制。
echo ------------------------------------------------
echo -------------------------------
echo 开始自动部署……
echo ------------------------------------------------
echo -------------------------------
echo [%BUILD_ID%]正在部署%project_sn%实体jar
for /r %project_tmp% %%i in (gxpt_entity_%project_sn%.jar) do (
echo 正在部署%%i 到 %project_default%
copy /y "%%i" "%project_default%"
)
echo ------------------------------------------------
echo -------------------------------
echo [%BUILD_ID%]正在部署commontool的jar
for /r %project_tmp% %%i in (gxpt_common_tool.jar) do (
echo 正在部署%%i 到 %project_default%
copy /y "%%i" "%project_default%"
)
echo ------------------------------------------------
echo -------------------------------
echo [%BUILD_ID%] 正在部署commonEao接口jar
for /r %project_tmp% %%i in (gxpt_common_eao.jar) do (
echo 正在部署%%i 到 %project_default%
copy /y "%%i" "%project_default%"
)
echo ------------------------------------------------
echo -------------------------------
echo [%BUILD_ID%] 正在部署commonEao实现jar
for /r %project_tmp% %%i in (gxpt_common_eao_impl.jar) do (
echo 正在部署%%i 到 %project_default%
copy /y "%%i" "%project_default%"
)
echo ------------------------------------------------
echo -------------------------------
echo [%BUILD_ID%] 正在部署%project_sn%的mgr层接口jar
if exist interface.txt del interface.txt
for /r %project_tmp% %%i in (gxpt_mgr_%project_sn%_*.jar) do (
echo "%%i"|find "impl" /I>interface.txt
set "zer=%%i"
for /f "delims=." %%j in (interface.txt) do (
set "zer=null"
)
if not "!zer!"=="null" (
echo 正在部署%%i 到 %project_default%
copy /y "%%i" "%project_default%"
)
)
if exist interface.txt del interface.txt
echo ------------------------------------------------
echo -------------------------------
echo [%BUILD_ID%] 正在部署%project_sn%的mgr层实现jar
for /r %project_tmp% %%i in (gxpt_mgr_%project_sn%_*_impl.jar) do (
echo 正在部署%%i 到 %project_default%
copy /y "%%i" "%project_default%"
)
echo ------------------------------------------------
echo -------------------------------
echo [%BUILD_ID%] 正在部署%project_sn%的war
for /r %project_tmp% %%i in (gxpt_web_%project_sn%_*.war) do (
echo 正在部署%%i 到 %project_default%
copy /y "%%i" "%project_default%"
)
echo ------------------------------------------------
echo -------------------------------
echo [%BUILD_ID%] %project_sn%项目部署完成。
@echo off & setlocal EnableDelayedExpansion
set jboss_path=Y:
set project_sn=%1
set project_default=%jboss_path%\default-%project_sn%\deploy\
set project_home=D:\Jenkins
set project_tmp=%project_home%\tmp_%project_sn%
set project_workspace=%project_home%\workspace
set workspace=%project_workspace%\gxpt_%project_sn%_main
if not exist %project_tmp% md %project_tmp%
echo [%BUILD_ID%] 正在检索所有jar包和war包到%project_tmp%临时目录
echo -------------------------------
echo ---------------------
for /f %%i in (%WORKSPACE%\%project_sn%_deploy_sequence.txt) do (
if exist "%project_workspace%\%%i\target\%%i.jar" (
echo 正在复制%%i到%project_tmp%\
copy /y "%project_workspace%\%%i\target\%%i.jar" %project_tmp%\
)
)
for /f %%i in (%WORKSPACE%\%project_sn%_deploy_sequence.txt) do (
if exist "%project_workspace%\%%i\target\%%i.war" (
echo 正在复制%%i到%project_tmp%\
copy /y "%project_workspace%\%%i\target\%%i.war" %project_tmp%\
)
)
echo -------------------------------
echo ---------------------
echo [%BUILD_ID%] 完成复制。
echo ------------------------------------------------
echo -------------------------------
echo 开始自动部署……
echo ------------------------------------------------
echo -------------------------------
for /f %%i in (%WORKSPACE%\%project_sn%_deploy_sequence.txt) do (
if exist "%project_tmp%\%%i.jar" (
echo 正在部署%%i 到 %project_default%
copy /y "%project_tmp%\%%i.jar" "%project_default%"
)
)
for /f %%i in (%WORKSPACE%\%project_sn%_deploy_sequence.txt) do (
if exist "%project_tmp%\%%i.war" (
echo 正在部署%%i 到 %project_default%
copy /y "%project_tmp%\%%i.war" "%project_default%"
)
)
echo ------------------------------------------------
echo -------------------------------
echo [%BUILD_ID%] %project_sn%项目部署完毕。
Use this at your own risk. (I have tested it on XP and Server 2008 x64 R2)
For this hack you will need SysinternalsSuite by Mark Russinovich:
Step one: Open an elevated cmd.exe prompt (Run as administrator)
Step two: Elevate again to root using PSExec.exe: Navigate to the folder containing SysinternalsSuite and execute the following command psexec -i -s cmd.exe
you are now inside of a prompt that is nt authority\system
and you can prove this by typingwhoami
. The -i
is needed because drive mappings need to interact with the user
Step Three: Create the persistent mapped drive as the SYSTEM account with the following command net use z: \\servername\sharedfolder /persistent:yes
It's that easy!
WARNING: You can only remove this mapping the same way you created it, from the SYSTEM account. If you need to remove it, follow steps 1 and 2 but change the command on step 3 to net use z: /delete
.
NOTE: The newly created mapped drive will now appear for ALL users of this system but they will see it displayed as "Disconnected Network Drive (Z:)". Do not let the name fool you. It may claim to be disconnected but it will work for everyone. That's how you can tell this hack is not supported by M$.
更多推荐
所有评论(0)