项目需要,shell脚本自动化替换文档内容,并提交代码 3ff8
2017-10-31 10:53
323 查看
项目需要,shell脚本自动化替换文档内容,并提交代码
#!/bin/bash
if [ ! $commitTag ]; then
echo "commitTag IS NULL"
exit
fi
echo ".........................push code start ..............................."
#root根目录
#rootPath=/Users/user/git/myelong
rootPath=/home/hudson/workspace
#前端最后一次提交commit,参入传入
#commitTag=316cb08031dc96c185d35d934d0264374255d95b
#后端项目空壳分支,由CI系统传入
#branch=b171102
#定义文件模版路径,即各个需要替换前端资源的模版文件路径
templatePath=$rootPath'/h5-hotelwxqb-web/src/main/resources/template'
#定义文件产出路径,即最终提交git的文件路径
outputPath=$rootPath'/h5-hotelwxqb-web/src/main/resources/config'
#从git上拉项目到本地,前端项目和后端项目都需要拉下来
cd $rootPath
#拉前端项目
git clone http://code.corp.elong.com/xy-team/hotelfx-static-resource-reference.git cd hotelfx-static-resource-reference
git init
git checkout $commitTag
#前端首页js代码文本
indexJSTxt=$(cat index.js)
#前端列表页js代码文本
listJsTxt=$(cat list.js)
#前端快速预定列表页js代码文本
flistJsTxt=$(cat flist.js)
#前端详情页js代码文本
detailJsTxt=$(cat detail.js)
#前端订单填写页js代码文本
createOderJsTxt=$(cat createorder.js)
#拉后端项目
cd $rootPath
git clone git@code.corp.elong.com:h5-website/h5-hotelwxqb-web.git
cd h5-hotelwxqb-web
git init
git checkout $branch
git pull
#替换首页前端资源
replace_index(){
#定义本地文件路径
sourceFile=$templatePath/index.txt
destFile=$outputPath/spamvtbody2_alpha.txt
destFile2=$outputPath/spamvtbody2_beta.txt
#复制本地文件模版文件,修改目标文件内容
cat $sourceFile > $destFile
echo $indexJSTxt >> $destFile
cp $destFile $destFile2
}
#替换列表页前端资源
replace_list(){
#从本地列表页模版文件替换前端资源路径,生成新列表页配置文件
sourceFile=$templatePath/list.txt
sourceFootFile=$templatePath/foot.txt
destFile=$outputPath/webapp-config-list.xml
#复制本地文件模版文件,修改目标文件内容
cat $sourceFile > $destFile
echo $listJsTxt >> $destFile
cat $sourceFootFile >> $destFile
}
#替换快速预定前端资源
replace_flist(){
#从本地列表页模版文件替换前端资源路径,生成新列表页配置文件
sourceFile=$templatePath/flist.txt
sourceFootFile=$templatePath/foot.txt
destFile=$outputPath/webapp-config-flist.xml
#复制本地文件模版文件,修改目标文件内容
cat $sourceFile > $destFile
echo $flistJsTxt >> $destFile
cat $sourceFootFile >> $destFile
}
#替换详情页前端资源
replace_detail(){
#从本地详情页模版文件替换前端资源路径,生成新详情页配置文件
sourceFile=$templatePath/detail.txt
sourceFootFile=$templatePath/foot.txt
destFile=$outputPath/webapp-config-detail.xml
#复制本地文件模版文件,修改目标文件内容
cat $sourceFile > $destFile
echo $detailJsTxt >> $destFile
cat $sourceFootFile >> $destFile
}
#替换订单填写页前端资源
replace_createorder(){
#从本地订单填写页模版文件替换前端资源路径,生成新订单填写页配置文件
sourceFile=$templatePath/createorder.txt
sourceFootFile=$templatePath/foot.txt
destFile=$outputPath/webapp-config-createorder.xml
#复制本地文件模版文件,修改目标文件内容
cat $sourceFile > $destFile
echo $createOderJsTxt >> $destFile
cat $sourceFootFile >> $destFile
}
#替换程序里的各个页面前端资源代码
replace_index
replace_list
replace_flist
replace_detail
replace_createorder
#代码提交到git上
git add -A
git commit -am 'update web script '$branch
#git pull
git push origin $branch
echo ".........................push code end ..............................."
#删除前端资源项目
cd $rootPath
rm -rf H5_JAVA_GIT_HOTELWXQB_WEB
mv h5-hotelwxqb-web H5_JAVA_GIT_HOTELWXQB_WEB
rm -rf hotelfx-static-resource-reference
#!/bin/bash
if [ ! $commitTag ]; then
echo "commitTag IS NULL"
exit
fi
echo ".........................push code start ..............................."
#root根目录
#rootPath=/Users/user/git/myelong
rootPath=/home/hudson/workspace
#前端最后一次提交commit,参入传入
#commitTag=316cb08031dc96c185d35d934d0264374255d95b
#后端项目空壳分支,由CI系统传入
#branch=b171102
#定义文件模版路径,即各个需要替换前端资源的模版文件路径
templatePath=$rootPath'/h5-hotelwxqb-web/src/main/resources/template'
#定义文件产出路径,即最终提交git的文件路径
outputPath=$rootPath'/h5-hotelwxqb-web/src/main/resources/config'
#从git上拉项目到本地,前端项目和后端项目都需要拉下来
cd $rootPath
#拉前端项目
git clone http://code.corp.elong.com/xy-team/hotelfx-static-resource-reference.git cd hotelfx-static-resource-reference
git init
git checkout $commitTag
#前端首页js代码文本
indexJSTxt=$(cat index.js)
#前端列表页js代码文本
listJsTxt=$(cat list.js)
#前端快速预定列表页js代码文本
flistJsTxt=$(cat flist.js)
#前端详情页js代码文本
detailJsTxt=$(cat detail.js)
#前端订单填写页js代码文本
createOderJsTxt=$(cat createorder.js)
#拉后端项目
cd $rootPath
git clone git@code.corp.elong.com:h5-website/h5-hotelwxqb-web.git
cd h5-hotelwxqb-web
git init
git checkout $branch
git pull
#替换首页前端资源
replace_index(){
#定义本地文件路径
sourceFile=$templatePath/index.txt
destFile=$outputPath/spamvtbody2_alpha.txt
destFile2=$outputPath/spamvtbody2_beta.txt
#复制本地文件模版文件,修改目标文件内容
cat $sourceFile > $destFile
echo $indexJSTxt >> $destFile
cp $destFile $destFile2
}
#替换列表页前端资源
replace_list(){
#从本地列表页模版文件替换前端资源路径,生成新列表页配置文件
sourceFile=$templatePath/list.txt
sourceFootFile=$templatePath/foot.txt
destFile=$outputPath/webapp-config-list.xml
#复制本地文件模版文件,修改目标文件内容
cat $sourceFile > $destFile
echo $listJsTxt >> $destFile
cat $sourceFootFile >> $destFile
}
#替换快速预定前端资源
replace_flist(){
#从本地列表页模版文件替换前端资源路径,生成新列表页配置文件
sourceFile=$templatePath/flist.txt
sourceFootFile=$templatePath/foot.txt
destFile=$outputPath/webapp-config-flist.xml
#复制本地文件模版文件,修改目标文件内容
cat $sourceFile > $destFile
echo $flistJsTxt >> $destFile
cat $sourceFootFile >> $destFile
}
#替换详情页前端资源
replace_detail(){
#从本地详情页模版文件替换前端资源路径,生成新详情页配置文件
sourceFile=$templatePath/detail.txt
sourceFootFile=$templatePath/foot.txt
destFile=$outputPath/webapp-config-detail.xml
#复制本地文件模版文件,修改目标文件内容
cat $sourceFile > $destFile
echo $detailJsTxt >> $destFile
cat $sourceFootFile >> $destFile
}
#替换订单填写页前端资源
replace_createorder(){
#从本地订单填写页模版文件替换前端资源路径,生成新订单填写页配置文件
sourceFile=$templatePath/createorder.txt
sourceFootFile=$templatePath/foot.txt
destFile=$outputPath/webapp-config-createorder.xml
#复制本地文件模版文件,修改目标文件内容
cat $sourceFile > $destFile
echo $createOderJsTxt >> $destFile
cat $sourceFootFile >> $destFile
}
#替换程序里的各个页面前端资源代码
replace_index
replace_list
replace_flist
replace_detail
replace_createorder
#代码提交到git上
git add -A
git commit -am 'update web script '$branch
#git pull
git push origin $branch
echo ".........................push code end ..............................."
#删除前端资源项目
cd $rootPath
rm -rf H5_JAVA_GIT_HOTELWXQB_WEB
mv h5-hotelwxqb-web H5_JAVA_GIT_HOTELWXQB_WEB
rm -rf hotelfx-static-resource-reference
相关文章推荐
- shell脚本编程:将文件中指定行的内容进行替换
- android中执行shell脚本或者需要root权限代码的方法
- 一个项目需要提交哪了些文档?
- iOS自动化编译打包提交-Shell脚本实现
- 提交的项目是否需要内容审批
- 执行shell脚本时,遇到需要输入yes/no的时候,怎么自动化完成输入呢?
- 详解Shell脚本实现iOS自动化编译打包提交
- 提交的项目是否需要内容审批
- 最近做的Android项目,和同事分开做的,所以需要写一些文档注释,说明自己的工作内容
- Shell脚本,自动化发布tomcat项目【转载】
- Ubuntu下定时提交代码到SVN服务器的Shell脚本分享
- 手游公司运维之利用Rundeck自动化运维工具和Shell脚本构建测试环境代码发布平台和生产环境代码发布平台
- linux下使用shell脚本自动化部署项目
- 备份网站内容的shell脚本代码
- Ubuntu下定时提交代码到SVN服务器的Shell脚本分享
- shell脚本,用awk实现替换文件里面的内容。
- 自动化部署java maven项目到多个目标主机的Shell脚本
- 在shell脚本嵌入except代码实现免交互自动化
- linux下使用shell脚本自动化部署项目
- Shell脚本,自动化发布tomcat项目【转】