版本基线自动化之Linux

上一篇笔者叙述了如何在windows平台上进行自动化打包,这次采用linux平台

1、start.bat : 调用cleanall.bat脚本 ,从svn服务器中检出代码,并采用7-Zip工具进行压缩并调用teasefile.bat脚本和output_linux.bat脚本;

  1.1、cleanall.bat:  清除环境 并利用secureCRT执行vbs脚本> aloneclean.vbs

  1.2、teasefile.bat:  将压缩包利用secureCRT工具中的sfxcl命令发送到linux编译服务器中 并利用CRT执行解压> gunzupScript.vbs

  1.3、output_linux.bat:  编译项目 >antcompilerScript.vbs,这里我也是采用的是ant进行编译java,c使用gcc编译,利用smb实现linux文件共享,将安装程序复制到svn服务器中,最后打开程序所在的位置即可;

start.bat

rem clean D:ybworkspace*
rem Create by dq
rem Create date 2017/5/10

@echo off

set _work=D:yb6.0workspace
set _log=D:	oolscompilerprojectalonecleanlog.txt
set _console=%_work%console
set _ldapserver=%_work%ldapserver
set _package=%_work%package
set _package(windxldap)=%_work%package(winxldap)
set _trunk_win=%_work%	runk_win.rar
cd /d %_work%
 del /s /q %_trunk_win% 
 rd /s /q %_work%.svn
 rd /s /q %_console% 
 rd /s /q %_ldapserver% 
 rd /s /q %_package% 
 rd /s /q %_package(windxldap)% 

cleanall.bat

rem clean source code and installation package            
rem Create by dq
rem Create date 2017/4/30

set _work=D:ybQHLDAP6.0src
set _setup=D:目录服务管理系统V6.0QH-LDAP_6.01.001安装包Linux


rem clean 192.168.0.234:D:ybworkspace* D:ybLog

rd /q /s %_work%Linux 


rem clean installation package

rd /q /s %_setup%* 


rem clean 192.168.0.92:/yb/work/*

cd /d D:ybSecureCRT 
SecureCRT.exe /LOG D:ybclean.txt /SCRIPT  Scripts/aloneclean.vbs  -2 root@192.168.0.92 /password qihang

aloneclean.vbs

#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

' This automatically generated script may need to be
' edited in order to work correctly.

Sub Main
	crt.Screen.Send "cd /" & chr(13)
	crt.Screen.WaitForString "[root@localhost /]# "
	crt.Screen.Send "cd /y" & chr(9) & "w" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "rm -rf s" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "rm 0" & chr(8) & "=-" & chr(8) & chr(8) & "=" & chr(8) & "-rf o" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "rm -rf o" & chr(8) & "p" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "rm -rf c" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Session.Disconnect
	crt.Quit
End Sub

teasefile.bat

rem send source code             
rem Create by dq
rem Create date 2017/5/10


rem send to Linux

cd /d D:ybSecureCRT
sfxcl "D:ybQHLDAP6.0src	runk_lin.gzip" sftp://root:qihang@192.168.0.92/../yb/work


rem run 'gunzipScript' script

SecureCRT.exe  /SCRIPT  Scripts/gunzipScript.vbs  -2 root@192.168.0.92 /password qihang 

gunzipScript.vbs

#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

' This automatically generated script may need to be
' edited in order to work correctly.

Sub Main
	crt.Screen.Send "cd /" & chr(13)
	crt.Screen.WaitForString "[root@localhost /]# "
	crt.Screen.Send "cd /yb/w" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "tar xvf t" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "ls" & chr(13)
	crt.Screen.WaitForString chr(27) & "[m[root@localhost work]# "
	crt.Screen.Send "rm -rf t" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost work]# "
	crt.Screen.Send "ls" & chr(13)
	crt.Session.Disconnect
	crt.Quit
End Sub

output_linux.bat

rem stop mstsc.exe; open release folder 			
rem Create by dq
rem Create date 2017/5/2


rem run 'compilerScript' scirpt

cd /d D:ybSecureCRT
SecureCRT.exe  /SCRIPT  Scripts/antcompilerScript.vbs  -2 root@192.168.0.92 /password qihang


rem long-distance copy installation project

net use * /del /y
net use \192.168.0.92public P@ssw0rd /user:root
copy \192.168.0.92public* D:目录服务管理系统V6.0QH-LDAP_6.01.001安装包Linuxsetup


rem open installation project 

dir D:
start D:目录服务管理系统V6.0QH-LDAP_6.01.001安装包Linux
@exit

antcompilerScript.vbs

#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

' This automatically generated script may need to be
' edited in order to work correctly.

Sub Main
	crt.Screen.Send "cd /" & chr(13)
	crt.Screen.WaitForString "[root@localhost /]# "
	crt.Screen.Send "cd" & chr(8) & chr(8) & "chmod -R 777 /y" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost /]# "
	crt.Screen.Send "cd /yb" & chr(9) & "comp" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost compilerproject]# "
	crt.Screen.Send "ant -f init.xml" & chr(13)
	crt.Screen.WaitForString "[root@localhost compilerproject]# "
	crt.Screen.Send "ant -f Ld" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost compilerproject]# "
	crt.Screen.Send "cd /" & chr(13)
	crt.Screen.WaitForString "[root@localhost /]# "
	crt.Screen.Send "chmod -R 777 /y" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost /]# "
	crt.Screen.Send "cd /yb/work/package-x/QHLdap-Web/WEB/web/webapp/LDAPProject/WEB-INF/classes" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost classes]# "
	crt.Screen.Send "rm -f *.jar" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost classes]# "
	crt.Screen.Send "chmod -R 777 /y" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost classes]# "
	crt.Screen.Send "cd /yb" & chr(9) & "w" & chr(9) & "s" & chr(9) & "qh" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost qhldap-1.0]# "
	crt.Screen.Send "ls" & chr(13)
	crt.Screen.WaitForString chr(27) & "[m[root@localhost qhldap-1.0]# "
	crt.Screen.Send "./ldap-" & chr(9) & ".sh" & chr(13)
	crt.Screen.WaitForString "[root@localhost qhldap-1.0]# "
	crt.Screen.Send "cd /y" & chr(9) & "w" & chr(9) & "p" & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost package-x]# "
	crt.Screen.Send "./package." & chr(9) & chr(13)
	crt.Screen.WaitForString "[root@localhost package-x]# "
	crt.Screen.Send chr(13)
	crt.Screen.WaitForString "[root@localhost package-x]# "
	crt.Screen.Send chr(13)
	crt.Session.Disconnect
	crt.Quit
End Sub

这里笔者说下如何使用Samba共享文件

安装Samba

1)  检查是否安装  rpm –qa | grep samba

2)  修改/etc/samba/smb.conf

workgroup = WORKGROUP

hosts allow=192.168.0.234

3)  在文件的结尾加上

[public]

comment=Public Stuff

path = /yb/wroktest

public = yes

writable =yes

4)  重启服务: service smb restart

5)  创建samba客户:smbpasswd –a root回车后提示输入密码这里的root必须在系统已经存在

6)  Windows下链接,启动运行,输入Linux的ip :\192.168.0.92 输入smb账号密码就可以了

原文地址:https://www.cnblogs.com/dqcer/p/8443904.html