From 1618ebd86849b89ce0ba2518d403c384f07db822 Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Mon, 10 Jan 2022 09:22:38 +0800 Subject: [PATCH 1/5] drone --- .drone.yml | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 00000000..fa4b229e --- /dev/null +++ b/.drone.yml @@ -0,0 +1,134 @@ +kind: pipeline +type: docker +name: default + +# 挂载的主机卷,可以映射到docker容器中 +volumes: + # maven构建缓存(宿主机目录) + - name: ssh_key + host: + path: /root/.ssh/ + - name: cache + host: + path: /var/lib/cache + - name: data + host: + path: /var/lib/data + +steps: + - name: test + image: alpine + pull: if-not-exists + commands: + - echo hello + - echo world + + - name: build-maven + image: maven:3.8.4-jdk-8 + pull: if-not-exists # default always + volumes: + - name: cache + path: /root/.m2 + commands: + - ls + - mvn -version + - java -version + - mvn clean install -Dmaven.test.skip=true + +# - name: deploy-scp +# image: appleboy/drone-scp +# pull: if-not-exists +# volumes: +# - name: ssh_key +# path: /root/.ssh/ +# settings: +# host: test.tall.wiki +# port: 22 +# username: root +# key_path: /root/.ssh/id_rsa +# rm: false # true则会删除目标目录重建 +# target: /home/iacd-platform-drone +# source: target/*.jar +# strip_components: 1 # 去除的目录层数,如果没有该选项,则拷贝过去是 target/xxx.jar,1代表去除target +# +# - name: run-ssh +# image: appleboy/drone-ssh +# pull: if-not-exists +# volumes: +# - name: ssh_key +# path: /root/.ssh/ +# settings: +# settings: +# host: test.tall.wiki +# port: 22 +# username: root +# key_path: /root/.ssh/id_rsa +# script_stop: true # stop script after first failure +# #command_timeout: 30s # 30seconds, the maximum amount of time for the execute commands, default is 10 minutes. +# script: +# - cd /home/iacd-platform-drone +# - ./re.sh > /dev/null 2> /dev/null & + + - name: notify-email + image: drillster/drone-email + pull: if-not-exists + settings: + host: smtp.qiye.aliyun.com #例如 smtp.qq.com + port: 465 #例如QQ邮箱端口465 + username: devops@ccsens.com #邮箱用户名 + password: #邮箱密码 + from_secret: orgsecret_password_mail_devops + from: devops@ccsens.com + recipients: weizezhao@ccsens.com,wuhuijuan@ccsens.com #收件人,多个用,隔开 + when: #执行条件 + status: + - success + - changed + - failure + + - name: notify-wechatwork + image: fifsky/drone-wechat-work + pull: if-not-exists + settings: + url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=b2b93e9a-128b-41d4-8dce-12004e3f48b9 + msgtype: markdown + content: | + {{if eq .Status "success" }} + #### 🎉 ${DRONE_REPO} 构建成功 + > Commit: [${DRONE_COMMIT_MESSAGE}](${DRONE_COMMIT_LINK}) + > Author: ${DRONE_COMMIT_AUTHOR} + > [点击查看](${DRONE_BUILD_LINK}) + {{else}} + #### ❌ ${DRONE_REPO} 构建失败 + > Commit: [${DRONE_COMMIT_MESSAGE}](${DRONE_COMMIT_LINK}) + > Author: ${DRONE_COMMIT_AUTHOR} + > 请立即修复!!! + > [点击查看](${DRONE_BUILD_LINK}) + {{end}} + when: + status: + - failure + - success + + # - name: notify-dingtalk + # image: lddsb/drone-dingtalk-message + # environment: + # PASSWORD: + # from_secret: password_mail_devops + # settings: + # token: your-dingtalk-robot-access-token + # type: markdown + # message_color: true + # message_pic: true + # sha_link: true + + # -name: notify-slack + # image: plugins/slack + # webhook: https://hooks.slack.com/ www.dijiuyy.com services/xxx/xxx/xxx + # channel: dev + # template: > + # {{#success build.status}} + # build {{build.number}} succeeded. Good job. + # {{else}} + # build {{build.number}} failed. Fix me please. + # {{/success}} \ No newline at end of file From 10b3666e5af04f656d04e73d57a1db4079b23d6e Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Thu, 20 Jan 2022 11:21:48 +0800 Subject: [PATCH 2/5] drone test --- .drone.yml | 149 +++++++++++++++++++++++++++++------------------------ 1 file changed, 82 insertions(+), 67 deletions(-) diff --git a/.drone.yml b/.drone.yml index fa4b229e..6eb0e5dd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,95 +2,93 @@ kind: pipeline type: docker name: default +# workspace,path可设定默认的拉取目录和每个step中docker镜像的chdir目录,通常不需要设置 +# workspace官方说明:https://docs.drone.io/yaml/docker/#the-workspace-object +# 可在repo->setting中设置secret,使用from_secret引用密钥 + +# 常量值 +constants: + - &SERVER_HOST test.tall.wiki + - &SERVER_PORT 30022 + - &BUILD_CMDER + - ls + - mvn -version + - java -version + - mvn clean install -Dmaven.test.skip=true + - &SCP_TARGET /home/cloud/tall3 + - &SCP_SOURCE target/signin-1.0-SNAPSHOT.jar + - &SCP_STRIP_DIR_LEVEL 1 + - &SSH_CMDER + - cd /home/cloud/tall3 + - pwd + - ./tall3.sh > /dev/null 2> /dev/null & + #- &NOTIFY_EMAIL weizezhao@ccsens.com + - &NOTIFY_WECHATROBOT_WEBHOOK https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=b2b93e9a-128b-41d4-8dce-12004e3f48b9 + # 挂载的主机卷,可以映射到docker容器中 volumes: - # maven构建缓存(宿主机目录) - name: ssh_key host: path: /root/.ssh/ - name: cache host: path: /var/lib/cache - - name: data - host: - path: /var/lib/data +# 执行触发器 +trigger: + branch: + - yanyuan + - drone + +# 构建阶段 steps: - - name: test - image: alpine - pull: if-not-exists - commands: - - echo hello - - echo world - - name: build-maven image: maven:3.8.4-jdk-8 pull: if-not-exists # default always volumes: - - name: cache - path: /root/.m2 - commands: - - ls - - mvn -version - - java -version - - mvn clean install -Dmaven.test.skip=true + - name: cache + path: /root/.m2 + commands: *BUILD_CMDER + + - name: deploy-scp + image: appleboy/drone-scp + pull: if-not-exists + volumes: + - name: ssh_key + path: /root/.ssh/ + settings: + host: *SERVER_HOST + port: *SERVER_PORT + username: root + key_path: /root/.ssh/id_rsa + rm: false # true则会删除目标目录重建 + target: *SCP_TARGET + source: *SCP_SOURCE + strip_components: *SCP_STRIP_DIR_LEVEL # 去除的目录层数,如果没有该选项,则拷贝过去是 target/xxx.jar,1代表去除target -# - name: deploy-scp -# image: appleboy/drone-scp -# pull: if-not-exists -# volumes: -# - name: ssh_key -# path: /root/.ssh/ -# settings: -# host: test.tall.wiki -# port: 22 -# username: root -# key_path: /root/.ssh/id_rsa -# rm: false # true则会删除目标目录重建 -# target: /home/iacd-platform-drone -# source: target/*.jar -# strip_components: 1 # 去除的目录层数,如果没有该选项,则拷贝过去是 target/xxx.jar,1代表去除target -# -# - name: run-ssh -# image: appleboy/drone-ssh -# pull: if-not-exists -# volumes: -# - name: ssh_key -# path: /root/.ssh/ -# settings: -# settings: -# host: test.tall.wiki -# port: 22 -# username: root -# key_path: /root/.ssh/id_rsa -# script_stop: true # stop script after first failure -# #command_timeout: 30s # 30seconds, the maximum amount of time for the execute commands, default is 10 minutes. -# script: -# - cd /home/iacd-platform-drone -# - ./re.sh > /dev/null 2> /dev/null & - - - name: notify-email - image: drillster/drone-email + - name: run-ssh + image: appleboy/drone-ssh pull: if-not-exists + volumes: + - name: ssh_key + path: /root/.ssh/ settings: - host: smtp.qiye.aliyun.com #例如 smtp.qq.com - port: 465 #例如QQ邮箱端口465 - username: devops@ccsens.com #邮箱用户名 - password: #邮箱密码 - from_secret: orgsecret_password_mail_devops - from: devops@ccsens.com - recipients: weizezhao@ccsens.com,wuhuijuan@ccsens.com #收件人,多个用,隔开 - when: #执行条件 - status: - - success - - changed - - failure + settings: + host: *SERVER_HOST + port: *SERVER_PORT + username: root + key_path: /root/.ssh/id_rsa + script_stop: true # stop script after first failure + #command_timeout: 30s # 30seconds, the maximum amount of time for the execute commands, default is 10 minutes. + script: *SSH_CMDER + #- cd /home/cloud/tall3 + #- ./re.sh > /dev/null 2> /dev/null & - name: notify-wechatwork image: fifsky/drone-wechat-work pull: if-not-exists settings: - url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=b2b93e9a-128b-41d4-8dce-12004e3f48b9 + url: *NOTIFY_WECHATROBOT_WEBHOOK msgtype: markdown content: | {{if eq .Status "success" }} @@ -110,6 +108,23 @@ steps: - failure - success + # - name: notify-email + # image: drillster/drone-email + # pull: if-not-exists + # settings: + # host: smtp.qiye.aliyun.com #例如 smtp.qq.com + # port: 465 #例如QQ邮箱端口465 + # username: devops@ccsens.com #邮箱用户名 + # password: #邮箱密码 + # from_secret: orgsecret_password_mail_devops + # from: devops@ccsens.com + # recipients: *NOTIFY_EMAIL #收件人,多个用,隔开 + # when: #执行条件 + # status: + # - success + # - changed + # - failure + # - name: notify-dingtalk # image: lddsb/drone-dingtalk-message # environment: From 18b4b2672051d1dfe1020f67268e643f97c7c72c Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Thu, 20 Jan 2022 14:09:24 +0800 Subject: [PATCH 3/5] drone test --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 6eb0e5dd..8ac15dde 100644 --- a/.drone.yml +++ b/.drone.yml @@ -16,7 +16,7 @@ constants: - java -version - mvn clean install -Dmaven.test.skip=true - &SCP_TARGET /home/cloud/tall3 - - &SCP_SOURCE target/signin-1.0-SNAPSHOT.jar + - &SCP_SOURCE signin/target/*.jar - &SCP_STRIP_DIR_LEVEL 1 - &SSH_CMDER - cd /home/cloud/tall3 From 0ad3216c455852f094751409b85cee71cd74d10a Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Thu, 20 Jan 2022 14:18:14 +0800 Subject: [PATCH 4/5] drone test --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 8ac15dde..a78519b8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,7 +17,7 @@ constants: - mvn clean install -Dmaven.test.skip=true - &SCP_TARGET /home/cloud/tall3 - &SCP_SOURCE signin/target/*.jar - - &SCP_STRIP_DIR_LEVEL 1 + - &SCP_STRIP_DIR_LEVEL 2 - &SSH_CMDER - cd /home/cloud/tall3 - pwd From dc50cbfc9765268a3ea83b070d720a842fa33fdf Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Thu, 20 Jan 2022 14:26:27 +0800 Subject: [PATCH 5/5] drone test --- signin/src/main/resources/application.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/signin/src/main/resources/application.yml b/signin/src/main/resources/application.yml index dfe3200c..8b68bc6a 100644 --- a/signin/src/main/resources/application.yml +++ b/signin/src/main/resources/application.yml @@ -1,5 +1,5 @@ spring: profiles: - active: pre - include: util-pre, common + active: test + include: util-test, common