From bc7face67f2b8121f66fd7cf711ce674bf95536f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E9=A1=BA=E5=81=A5?= Date: Tue, 12 Apr 2022 10:53:23 +0000 Subject: [PATCH] =?UTF-8?q?build:=20=E6=96=B0=E5=A2=9E=20gitlab=20ci?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..a01d9ce85 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,87 @@ +# docker镜像 +image: git.mesalab.cn:7443/nezha/nz-build-env:1.3 +# 定义全局变量 +variables: + MINIO_HOST: 'http://192.168.44.36: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/ +# 定义的任务 +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 + - cd /builds/nezha/nezha-fronted/nezha-fronted/dist + - 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 alias set nz $MINIO_HOST $MINIO_USER $MINIO_PWD + - 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 + +# dev 分支,每15分钟自动编译一次 +dev_schedule: + rules: + - if: $CI_PIPELINE_SOURCE == "schedule" + # 所需执行的脚本 + script: + - env | sort + - pwd + - echo "npm install ..." + - cd nezha-fronted + - npm install --registry=http://registry.npmmirror.com + - echo "npm run build" + - npm run build + - cd /builds/nezha/nezha-fronted/nezha-fronted/dist + - export FILE_NAME=nz-gui-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA.zip + # 修改文件名,包含 commit id + - mv nz-gui*.zip $FILE_NAME + - md5sum $FILE_NAME > $FILE_NAME.md5sum.txt + # 将 dist zip 上传到 minio + - mc alias set nz $MINIO_HOST $MINIO_USER $MINIO_PWD + - mc cp $FILE_NAME nz/ci-cd/nz-gui/$FILE_NAME + - mc cp $FILE_NAME.md5sum.txt nz/ci-cd/nz-gui/$FILE_NAME.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_REF_NAME-$CI_COMMIT_SHORT_SHA.zip + expire_in: 1 day + # 指定哪个ci runner跑该工作 + tags: + - nezha