linux前端开发换金配置脚本,项目需要,shell脚本自动化替换文档内容,并提交代码...

项目需要,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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值