版本基线自动化之Linux

Posted dqcer

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了版本基线自动化之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:\yb\workspace\*
rem Create by dq
rem Create date 2017/5/10

@echo off

set _work=D:\yb\6.0\workspace
set _log=D:\tools\compilerproject\alone\cleanlog.txt
set _console=%_work%\console
set _ldapserver=%_work%\ldapserver
set _package=%_work%\package
set _package(windxldap)=%_work%\package(winxldap)
set _trunk_win=%_work%\trunk_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:\yb\QHLDAP\6.0\src
set _setup=D:\目录服务管理系统\V6.0\QH-LDAP_6.01.001\安装包\Linux


rem clean 192.168.0.234:D:\yb\workspace\* D:\yb\Log

rd /q /s %_work%\Linux 


rem clean installation package

rd /q /s %_setup%\* 


rem clean 192.168.0.92:/yb/work/*

cd /d D:\yb\SecureCRT 
SecureCRT.exe /LOG D:\yb\clean.txt /SCRIPT  Scripts/aloneclean.vbs  -2 [email protected] /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 "[[email protected] /]# "
	crt.Screen.Send "cd /y" & chr(9) & "w" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] work]# "
	crt.Screen.Send "rm -rf s" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] work]# "
	crt.Screen.Send "rm 0" & chr(8) & "=-" & chr(8) & chr(8) & "=" & chr(8) & "-rf o" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] work]# "
	crt.Screen.Send "rm -rf o" & chr(8) & "p" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] work]# "
	crt.Screen.Send "rm -rf c" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] 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:\yb\SecureCRT
sfxcl "D:\yb\QHLDAP\6.0\src\trunk_lin.gzip" sftp://root:qihang@192.168.0.92/../yb/work


rem run ‘gunzipScript‘ script

SecureCRT.exe  /SCRIPT  Scripts/gunzipScript.vbs  -2 [email protected] /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 "[[email protected] /]# "
	crt.Screen.Send "cd /yb/w" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] work]# "
	crt.Screen.Send "tar xvf t" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] work]# "
	crt.Screen.Send "ls" & chr(13)
	crt.Screen.WaitForString chr(27) & "[m[[email protected] work]# "
	crt.Screen.Send "rm -rf t" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] 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:\yb\SecureCRT
SecureCRT.exe  /SCRIPT  Scripts/antcompilerScript.vbs  -2 [email protected] /password qihang


rem long-distance copy installation project

net use * /del /y
net use \\192.168.0.92\public [email protected] /user:root
copy \\192.168.0.92\public\* D:\目录服务管理系统\V6.0\QH-LDAP_6.01.001\安装包\Linux\setup


rem open installation project 

dir D:start D:\目录服务管理系统\V6.0\QH-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 "[[email protected] /]# "
	crt.Screen.Send "cd" & chr(8) & chr(8) & "chmod -R 777 /y" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] /]# "
	crt.Screen.Send "cd /yb" & chr(9) & "comp" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] compilerproject]# "
	crt.Screen.Send "ant -f init.xml" & chr(13)
	crt.Screen.WaitForString "[[email protected] compilerproject]# "
	crt.Screen.Send "ant -f Ld" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] compilerproject]# "
	crt.Screen.Send "cd /" & chr(13)
	crt.Screen.WaitForString "[[email protected] /]# "
	crt.Screen.Send "chmod -R 777 /y" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] /]# "
	crt.Screen.Send "cd /yb/work/package-x/QHLdap-Web/WEB/web/webapp/LDAPProject/WEB-INF/classes" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] classes]# "
	crt.Screen.Send "rm -f *.jar" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] classes]# "
	crt.Screen.Send "chmod -R 777 /y" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] classes]# "
	crt.Screen.Send "cd /yb" & chr(9) & "w" & chr(9) & "s" & chr(9) & "qh" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] qhldap-1.0]# "
	crt.Screen.Send "ls" & chr(13)
	crt.Screen.WaitForString chr(27) & "[m[[email protected] qhldap-1.0]# "
	crt.Screen.Send "./ldap-" & chr(9) & ".sh" & chr(13)
	crt.Screen.WaitForString "[[email protected] qhldap-1.0]# "
	crt.Screen.Send "cd /y" & chr(9) & "w" & chr(9) & "p" & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] package-x]# "
	crt.Screen.Send "./package." & chr(9) & chr(13)
	crt.Screen.WaitForString "[[email protected] package-x]# "
	crt.Screen.Send chr(13)
	crt.Screen.WaitForString "[[email protected] 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账号密码就可以了

以上是关于版本基线自动化之Linux的主要内容,如果未能解决你的问题,请参考以下文章

linux基线核查脚本

敏捷开发之分之管理

敏捷开发之分支管理

丰富了一个linux基线核查脚本

回归测试是什么?(基线版本基线测试包代码相依性回归测试包软件操作剖面)

linux中怎么查看mysql数据库版本