116 lines
3.9 KiB
YAML
116 lines
3.9 KiB
YAML
# docker镜像
|
|
image: git.mesalab.cn:7443/nezha/nz-build-env:1.3
|
|
# 定义全局变量
|
|
variables:
|
|
MINIO_HOST: 'http://192.168.40.48:2020/'
|
|
MINIO_USER: 'admin'
|
|
MINIO_PWD: "Nezha@02!"
|
|
# 依赖的docker服务
|
|
# services:
|
|
# - mariadb
|
|
# - redis
|
|
# 开始执行脚本前所需执行脚本
|
|
before_script:
|
|
- echo "begin ci"
|
|
# 脚本执行完后的钩子,执行所需脚本
|
|
after_script:
|
|
- echo "end ci"
|
|
# 该ci pipeline适合的场景
|
|
stages:
|
|
- build
|
|
- test
|
|
# maven setting /usr/share/maven/conf/settings.xml
|
|
cache:
|
|
paths:
|
|
- /builds/nezha/nezha-fronted/nezha-fronted/node_modules/
|
|
|
|
|
|
# dev 分支
|
|
dev_build:
|
|
# 所需执行的脚本
|
|
script:
|
|
- env | sort
|
|
- pwd
|
|
- cd nezha-fronted
|
|
|
|
# 安装 npm 依赖文件
|
|
- echo "npm install ..."
|
|
- npm install --registry=http://registry.npmmirror.com
|
|
- echo "npm run build"
|
|
|
|
# 编译 上传模板
|
|
- npm run build:html
|
|
- mc alias set nz $MINIO_HOST $MINIO_USER $MINIO_PWD
|
|
- mkdir -p /builds/nezha/nezha-fronted/nezha-fronted/snapshot_template && cp dist/index.html /builds/nezha/nezha-fronted/nezha-fronted/snapshot_template/snapshot_template.html
|
|
|
|
- npm run build
|
|
- cd /builds/nezha/nezha-fronted/nezha-fronted/dist
|
|
- cp /builds/nezha/nezha-fronted/nezha-fronted/snapshot_template/snapshot_template.html ./snapshot_template.html
|
|
- rm -rf nz-gui*.zip
|
|
- export FILE_NAME=nz-gui-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA.zip
|
|
# 生成 git log 日志文件
|
|
- sed -i 's+</body>+<a style="position:fixed;bottom:20px;left:40px;z-index:999;color:white;" target="_blank" href="/static/git-log.html">更新记录</a>\n</body>+g' ./index.html;
|
|
# echo "<html>" > ./static/git-log.html
|
|
# echo "<head>" >> ./static/git-log.html
|
|
# echo '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">' >> ./static/git-log.html
|
|
# echo "</head>" >> ./static/git-log.html
|
|
# echo "<pre>" >> ./static/git-log.html
|
|
- "git log -100 --pretty=format:'%ad : %s' >> ./static/gui-log.html"
|
|
# echo "</pre></html>" >> ./static/git-log.html
|
|
- zip -q -r $FILE_NAME ./*
|
|
|
|
# 将 dist zip 上传到 minio
|
|
- mc cp $FILE_NAME nz/ci-cd/nz-gui/$FILE_NAME
|
|
- mc cp $FILE_NAME nz/ci-cd/nz-gui/nz-gui-$CI_COMMIT_REF_NAME-latest.zip
|
|
artifacts:
|
|
name: "nz-gui-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA"
|
|
when: on_success
|
|
paths:
|
|
- /builds/nezha/nezha-fronted/nezha-fronted/dist/nz-gui*.zip
|
|
expire_in: 1 day
|
|
# 在哪个分支上可用
|
|
only:
|
|
- /^dev-.*$/i
|
|
# 指定哪个ci runner跑该工作
|
|
tags:
|
|
- nezha
|
|
|
|
|
|
# release build
|
|
rel_build:
|
|
stage: build
|
|
# 所需执行的脚本
|
|
script:
|
|
- env | sort
|
|
- pwd
|
|
- echo "npm install ..."
|
|
- cd nezha-fronted
|
|
- npm install --registry=http://registry.npmmirror.com
|
|
- echo "npm run build"
|
|
|
|
- npm run build:html
|
|
- mc alias set nz $MINIO_HOST $MINIO_USER $MINIO_PWD
|
|
- mkdir -p /builds/nezha/nezha-fronted/nezha-fronted/snapshot_template && cp dist/index.html /builds/nezha/nezha-fronted/nezha-fronted/snapshot_template/snapshot_template.html
|
|
|
|
- npm run build
|
|
- cd /builds/nezha/nezha-fronted/nezha-fronted/dist
|
|
- cp /builds/nezha/nezha-fronted/nezha-fronted/snapshot_template/snapshot_template.html ./snapshot_template.html
|
|
- zip -m nz-gui*.zip ./snapshot_template.html
|
|
- mv nz-gui*.zip nz-gui-$CI_COMMIT_SHORT_SHA.zip
|
|
- md5sum nz-gui-$CI_COMMIT_SHORT_SHA.zip > nz-gui-$CI_COMMIT_SHORT_SHA.zip.md5sum.txt
|
|
- mc cp nz-gui-$CI_COMMIT_SHORT_SHA.zip nz/release/nz-gui/nz-gui-$CI_COMMIT_SHORT_SHA.zip
|
|
- mc cp nz-gui-$CI_COMMIT_SHORT_SHA.zip.md5sum.txt nz/release/nz-gui/nz-gui-$CI_COMMIT_SHORT_SHA.zip.md5sum.txt
|
|
artifacts:
|
|
name: "nz-gui-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA"
|
|
when: on_success
|
|
paths:
|
|
- /builds/nezha/nezha-fronted/nezha-fronted/dist/nz-gui-$CI_COMMIT_SHORT_SHA.zip
|
|
expire_in: 1 week
|
|
# 在哪个分支上可用
|
|
only:
|
|
- /^rel-.*$/i
|
|
# 指定哪个ci runner跑该工作
|
|
tags:
|
|
- nezha
|
|
|