阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

自动构建平台jenkins使用

150次阅读
没有评论

共计 6646 个字符,预计需要花费 17 分钟才能阅读完成。

自动化同步文档

一、本地同步准备
172.18.1.247 同步到 172.18.1.249
1、双击互信
注意不要破坏自动构建平台 172.18.1.247 的环境,只需要在 172.18.1.247 上复制 key 到其他节点即可。
# ssh-copy-id root@172.18.1.249
输入密码即可
2、在 172.18.1.249 上创建同步模块
安装 rsync 包
# yum –y install rsync
# vim /etc/rsyncd.conf
uid    = root
gid    = root
use chroot    = yes
max connections = 30
pid file=/var/run/rsyncd.pid
log file=/var/log/rsyncd.log
list = no
[www.linuxidc.com] #要同步到模块
uid=root      #授权的用户
gid=root      #授权用户所在地组
path          = /data/app/www.linuxidc.com  #模块对应的目录
hosts allow    = 172.18.1.0/24  #允许同步到主机 ip 范围
read only      = no  #是否只读

同步本地目录,让 172.18.1.249 主机可以同步文件
# chkconfig rsync on
# service xinetd start  //xinetd 服务是跟各种小文件传送相关的服务, 所以必须启动
# rsync –daemon –config=/etc/rsyncd.conf
创建同步模块对应的目录
# mkdir /data/app/www.linuxidc.com
# chown –R tomcat.tomcat /data/app/www.linuxidc.com
好了,本地做完了,做 172.18.1.247 自动构建平台上的配置

相关阅读

Linux 下构建 robotium+jenkins+TMTS 可持续集成自动化测试  http://www.linuxidc.com/Linux/2013-06/85633.htm

修改 Ubuntu 下的 jenkins 端口号 http://www.linuxidc.com/Linux/2013-06/85533.htm

Linux 搭建 jenkins http://www.linuxidc.com/Linux/2013-05/84619.htm

jenkins 服务器安装与配置 http://www.linuxidc.com/Linux/2013-05/84615.htm

jenkins 配置基于角色的项目权限管理 http://www.linuxidc.com/Linux/2013-05/84614.htm

Ubuntu Desktop 12.04 LTS 下安装 jenkins  http://www.linuxidc.com/Linux/2012-10/72459.htm

二、自动构建平台脚本配置

1、创建脚本目录
# cd /data/jenkins/scripts/
# mkidr linuxidc.3194
# cd linuxidc.3194/
# vim linuxidc_3194.sh #自动构建脚本

 

#!/bin/bash
eval `dirname$0`/env.sh
item=”linuxidc.3194″
TESTSERVER=172.18.1.249
WORKSPACE=”/data/jenkins/jobs/linuxidc 的日志上传 /workspace”
Test=0
# 创建中间站,作为导出 svn 版本包的中转站,导出并解压程序包
function init(){
cd$WORKSPACE
mkdir -p/dev/shm/$item
rm -rf/dev/shm/$item/*
TargetPack=`ls-t |grep -P “zip$|war$”|head -n 1`
cp -r$WORKSPACE/$TargetPack /dev/shm/$item/
cd/dev/shm/$item
unzip$TargetPack >/dev/null 2>&1
rm -f$TargetPack 2>/dev/null
}
#function modify_system_propety(){
# local flag
# flag=”$1″
# system_file=”/dev/shm/$item/WEB-INF/classes/plantform/system.properties”
# fromdos$system_file
# [-f$system_file] && cp/data/jenkins/scripts/linuxidc.3194/conf/system.properties $system_file
#
#}
#
# 修改日志文件
function modify_log4j(){
logfile=”/dev/shm/$item/WEB-INF/classes/log4j.properties”
fromdos$logfile
modifycommand=”
s@log4j.appender.file.File=.*@log4j.appender.file.File=/data/soft/tomcat_3194/logs/catalina.out@g”
[-f$logfile] && sed -i “$modifycommand” $logfile
}
# 修改数据库连接
function modify_dbconfig() {
localflag
flag=”$1″
if [“x$flag” == “xtest”]
then
/bin/cp /data/jenkins/scripts/linuxidc.3194/conf/test/* /dev/shm/$item/WEB-INF/classes/
elif [“x$flag” == “xproduct”]
then
/bin/cp/data/jenkins/scripts/linuxidc.3194/conf/product/* /dev/shm/$item/WEB-INF/classes/
fi
}
# 同步到测试服务器和共享存储
function depoly()
{
local flag
flag=”$1″
# 同步到测试服务器
if [“x$flag” == “xtest”]
then
domain=`echo “$TESTDOMAIN”|cut-d: -f1`
cd /dev/shm/$item && rsync -lrRptW–delete –contimeout=3 –exclude-from=/etc/list . $TESTSERVER::$domain
ssh$TESTSERVER “chown -R tomcat.tomcat /data/app/www.linuxidc.com_3194 &&/etc/init.d/tomcat_3194 restart”
# port=`echo”$APPDIR”|grep -o -P “\.\d+$”|sed “s/\.//g”`
# 同步到共享存储
elif [“x$flag” == “xproduct”]
then
ssh 172.18.3.24 “[! -d/mnt/share/deploy/dist/store/www.linuxidc.com.3194] && mkdir -p /mnt/share/deploy/dist/store/www.linuxidc.com.3194”
cd /dev/shm/$item && rsync -lrRptW–delete –exclude-from=/etc/list .172.18.3.24:/mnt/share/deploy/dist/store/www.linuxidc.com.3194
fi
}
init
#modify_system_propety
modify_log4j
#Test=0
echo $TESTSERVER
modify_dbconfig test
depoly test
#### 同步到共享存储
echo
modify_dbconfig product
depoly product

# vim env.sh #环境脚本,用来在自动构建平台上发邮件之用

#!/bin/bash
echo TESTDOMAIN=”www.linuxidc.com:3194″
echo TESTSERVER=”172.18.1.249″
echo APPDIR=”/data/app/www.linuxidc.com.3194″
echo APPLOG=”/data/soft/tomcat_3194/logs”
info=”/tmp/svninfo”
/usr/bin/svn log –username superadmin –password’jgxt!%-a.1315’svn://172.18.1.111/CPU/BLD/Server/linuxidcLOG/linuxidc_LOG_V0.003_20131125 |awk'{RS=”–“;}{if(NR==2){print $0}}’ > /tmp/svninfo
changetime=`grep ‘|’ $info |awk -F’|’ ‘{print $3}’`
author=`grep ‘|’ $info |awk -F’|’ ‘{print $2}’`
message=`grep -v ‘|’ $info|grep -P -i”v\d\.\d+_?(\d*)”|xargs|sed ‘s/ //g’`
messageall=`grep -v ‘|’ $info`
echo SVN_COMMIT_MSG=”$message”
echo SVN_COMMIT_MSG_ALL=”$messageall”
echo SVN_CHANGE_TIME=”$changetime”
echo SVN_COMMIT_AUTHOR=”$author”

可以创建一个配置文件的目录,存放其他需要修改的文件

# mkdir conf
# cd conf
# mkdir test 创建测试环境需要的目录
# mkdir product 创建生产环境需要的目录
# cd conf/test
# vim db.properties
123456789101112 #cmp
cmp.db.url=jdbc:postgresql://172.18.1.241:1921/cmp
cmp.db.user=cmp
cmp.db.pwd=aa(*&&^&a25pxpdf(*&e
#base
base.db.url=jdbc:postgresql://172.18.1.241:1921/base
base.db.user=base
base.db.pwd=b(*&a12s)((*idf(*&e
#channel
channel.db.url=jdbc:postgresql://172.18.1.242:1921/channel
channel.db.user=channel
channel.db.pwd=C30_fadfe_Fef3eDW389

 

# cd conf/product
# vim db.properties
#cmp
cmp.db.url=jdbc:postgresql://172.18.1.241:1921/cmp
cmp.db.user=cmp
cmp.db.pwd=aa(*&&^&a25pxpdf(*&e
#base
base.db.url=jdbc:postgresql://172.18.1.241:1921/base
base.db.user=base
base.db.pwd=b(*&a12s)((*idf(*&e
#channel
channel.db.url=jdbc:postgresql://172.18.1.242:1921/channel
channel.db.user=channel
channel.db.pwd=C30_fadfe_Fef3eDW389

——————————————————————————–
这些做完了之后,就去自动构建平台的 web 界面配置,构建吧。

http://115.238.91.226:60004/redmine/projects/ywxm/wiki/H2_%E6%9E%84%E5%BB%BA%E5%B9%B3%E5%8F%B0jenkins

自动构建平台点击构建完成后, 可以在测试环境监测 tomcat 启动的过程
1, 进入到 tomcat 的日志目录中
# cd /data/soft/tomcat_3194/logs
# service tomcat_3194 restart && tail -f catalina.out

可能会有以下报错
常见报错:exception
Java.io.FileNotFoundException: /overseas_memcached.log (Permission denied)
修改启动脚本,将 tomcat 的启动用户修改成 root,不要用 tomcat 用户启动
export TOMCAT_USER=root

java.net.UnknownHostException: playapp: playapp: Name or service not known
这个是主机名称错误, 编辑 hosts 文件,给主机加个别名
#vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 playapp

解决后重新启动就不会出错了.

自动化同步文档

一、本地同步准备
172.18.1.247 同步到 172.18.1.249
1、双击互信
注意不要破坏自动构建平台 172.18.1.247 的环境,只需要在 172.18.1.247 上复制 key 到其他节点即可。
# ssh-copy-id root@172.18.1.249
输入密码即可
2、在 172.18.1.249 上创建同步模块
安装 rsync 包
# yum –y install rsync
# vim /etc/rsyncd.conf
uid    = root
gid    = root
use chroot    = yes
max connections = 30
pid file=/var/run/rsyncd.pid
log file=/var/log/rsyncd.log
list = no
[www.linuxidc.com] #要同步到模块
uid=root      #授权的用户
gid=root      #授权用户所在地组
path          = /data/app/www.linuxidc.com  #模块对应的目录
hosts allow    = 172.18.1.0/24  #允许同步到主机 ip 范围
read only      = no  #是否只读

同步本地目录,让 172.18.1.249 主机可以同步文件
# chkconfig rsync on
# service xinetd start  //xinetd 服务是跟各种小文件传送相关的服务, 所以必须启动
# rsync –daemon –config=/etc/rsyncd.conf
创建同步模块对应的目录
# mkdir /data/app/www.linuxidc.com
# chown –R tomcat.tomcat /data/app/www.linuxidc.com
好了,本地做完了,做 172.18.1.247 自动构建平台上的配置

相关阅读

Linux 下构建 robotium+jenkins+TMTS 可持续集成自动化测试  http://www.linuxidc.com/Linux/2013-06/85633.htm

修改 Ubuntu 下的 jenkins 端口号 http://www.linuxidc.com/Linux/2013-06/85533.htm

Linux 搭建 jenkins http://www.linuxidc.com/Linux/2013-05/84619.htm

jenkins 服务器安装与配置 http://www.linuxidc.com/Linux/2013-05/84615.htm

jenkins 配置基于角色的项目权限管理 http://www.linuxidc.com/Linux/2013-05/84614.htm

Ubuntu Desktop 12.04 LTS 下安装 jenkins  http://www.linuxidc.com/Linux/2012-10/72459.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计6646字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中