You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
4.0 KiB
122 lines
4.0 KiB
kind: pipeline
|
|
type: docker
|
|
name: deploy
|
|
|
|
clone:
|
|
pull: if-not-exists
|
|
|
|
trigger:
|
|
branch:
|
|
- test
|
|
- master
|
|
event:
|
|
- push
|
|
# - pull_request
|
|
|
|
# k8s-node-03
|
|
#node_selector:
|
|
# drone: TRUE
|
|
|
|
volumes:
|
|
- name: node
|
|
host:
|
|
path: /data/drone/node_modules_daoshi/
|
|
- name: svn
|
|
host:
|
|
path: /data/drone/svndir/
|
|
|
|
steps:
|
|
- name: 代码构建
|
|
pull: if-not-exists
|
|
image: registry.cn-hangzhou.aliyuncs.com/tgabc-namespace/tgabc:node16-git-tools-20230118
|
|
volumes:
|
|
- name: node
|
|
path: /drone/src/node_modules
|
|
settings:
|
|
mirror: https://docker.mirrors.ustc.edu.cn
|
|
commands:
|
|
- npm config set registry https://registry.npm.taobao.org
|
|
- npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
|
|
- npm install
|
|
- npm run build
|
|
- ls dist
|
|
- mv CHANGELOG.md dist/
|
|
# - mkdir dist
|
|
|
|
- name: 获取tag数据
|
|
image: alpine/git:v2.36.2
|
|
commands:
|
|
- git fetch --tags
|
|
- git describe --tags `git rev-list --tags --max-count=1` > /drone/src/.tags
|
|
- cat /drone/src/.tags
|
|
|
|
- name: svn上传
|
|
pull: if-not-exists
|
|
image: registry.cn-hangzhou.aliyuncs.com/tgabc-namespace/tgabc:tools-20230116
|
|
volumes:
|
|
- name: svn
|
|
path: /svn
|
|
environment:
|
|
svn_server: svn://svn.k8s.1000my.com
|
|
svn_username: yanfa
|
|
svn_password: yanfa
|
|
commands:
|
|
# zip包
|
|
- zip_name=Navigation_h5_V3.0.0_${DRONE_REPO_NAME}_$(cat /drone/src/.tags).zip
|
|
- cd /drone/src/dist
|
|
- zip -q -r $zip_name ./*
|
|
- mv $zip_name ../
|
|
|
|
# svn目录定义 开头和结尾不能有/,且不能出现中文乱码,复制地址时建议只复制02项目定制后的目录,会影响到变量取值
|
|
- svndir="2022研发/Prd007_智能导视/02项目定制/BJ006北京京西大悦城/导视前端"
|
|
# - svn_reponame=${svndir%%/*}
|
|
# - svn_path=${svndir##*/}
|
|
# - echo 仓库内部子路径取值 $svn_path
|
|
# - echo 仓库列表名称取值 $svn_reponame
|
|
- svn_reponame=$(echo $svndir | awk -F/ '{print $1}')
|
|
- svn_path=$(echo $svndir | awk -F/ '{print $NF}')
|
|
- echo 仓库列表名称取值 $svn_reponame
|
|
- echo 仓库内部子路径取值 $svn_path
|
|
|
|
# - svn --username ${DRONE_REPO_NAMESPACE} --password ${DRONE_REPO_NAMESPACE} co svn://192.168.0.2/CI
|
|
# 更新到最新
|
|
- mkdir -p /svn/${DRONE_REPO_NAMESPACE}-${DRONE_REPO_NAME}
|
|
- cd /svn/${DRONE_REPO_NAMESPACE}-${DRONE_REPO_NAME}
|
|
- svn --username $svn_username --password $svn_password co svn://192.168.0.2/$svndir || true
|
|
- cd /svn/${DRONE_REPO_NAMESPACE}-${DRONE_REPO_NAME}/$svn_path
|
|
- svn update --non-interactive --username $svn_username --password $svn_password
|
|
|
|
# svn提交,需要在宿主机的挂载目录手动配置svnauth
|
|
- ls /drone/src/$zip_name
|
|
- mv /drone/src/$zip_name /svn/${DRONE_REPO_NAMESPACE}-${DRONE_REPO_NAME}/$svn_path/
|
|
- ls /svn/${DRONE_REPO_NAMESPACE}-${DRONE_REPO_NAME}/$svn_path/$zip_name
|
|
- svn add $zip_name
|
|
- svn ci -m "AutoCI" --non-interactive --username $svn_username --password $svn_password
|
|
|
|
# 创建仓库目录
|
|
# - upload_dir="${DRONE_REPO_NAMESPACE}"
|
|
# - mkdir -p $svndir/$upload_dir
|
|
# - svn add $(ls) || echo "目录已创建"
|
|
|
|
# 钉钉通知
|
|
- name: dingTalk notification
|
|
pull: if-not-exists
|
|
image: lddsb/drone-dingtalk-message
|
|
failure: ignore
|
|
settings:
|
|
token: 'your dingTalk robot token'
|
|
type: markdown
|
|
message_color: true
|
|
message_pic: true
|
|
sha_link: true
|
|
tips_title: '${CI_REPO_NAME}'
|
|
debug: true
|
|
success_color: '008000'
|
|
failure_color: 'FF0000'
|
|
tpl_repo_short_name: '${CI_REPO_NAME}'
|
|
msg_at_mobiles: ['15950312150']
|
|
success_pic: 'https://raw.githubusercontent.com/Ethan-Liuu/picture/master/success.png'
|
|
failure_pic: 'https://raw.githubusercontent.com/Ethan-Liuu/picture/master/failed.png'
|
|
tpl: '/drone/src/.tpl'
|
|
when:
|
|
status: [failure, success]
|
|
|