使用jenkins部署gitbook

声明

文章仅记录jenkins推送脚本和部分注解,方便个人复制使用。有基础的人可以参考。

# 环境变量
export GOROOT=/data/go1.9
export PATH=${PATH}:${GOROOT}/bin
export GOPATH=/home/tonnn/go

# 停止容器
#ssh -tt web@x.x.x.x ' \
#  docker container stop xyx_db_doc 2> /dev/null || true;
#'
  
# docker container ps -all --filter "name=xyx_db_doc" --format {{.ID}} |xargs --no-run-if-empty docker container stop ;
# rm
rm -rf ${GOPATH}/src/xyx-db-doc;

# clone
cd ${GOPATH}/src
git clone -b master https://username:password@host.git  xyx-db-doc --depth 1;
ls -l

# scp to dest
# scp -r xyx-db-doc web@x.x.x.x:/tmp/xyx-db-doc
rsync --delete -arvz xyx-db-doc  web@x.x.x.x:/home/web/projects/

# ssh and exec
ssh -tt web@x.x.x.x ' \
docker container stop xyx_db_doc 2> /dev/null || true; \
sleep 9; \
docker run -itd --name xyx_db_doc --rm -p 4001:4001 -p 35730:35730  -v /home/web/projects/xyx-db-doc:/xyx-db-doc fellah/gitbook:latest gitbook serve /xyx-db-doc/. --lrport 35730 --port 4001;'

# print ok
echo ok;

# clear
rm -rf ${GOPATH}/src/xyx-db-doc;

你可能感兴趣的:(gitbook,jenkins,jenkins,gitbook)