.drone.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. kind: pipeline
  2. name: default
  3. # type: ssh # 定义流水线类型,还有kubernetes、exec、docker等类型
  4. #server:
  5. # host: 127.0.0.1
  6. # user: root
  7. # password:
  8. # from_secret: passwdlocal # 可以在你的drone web界面设置里进行设置,这儿直接引用
  9. # 用的是树莓派所以架构要用arm64 正常 platform 这项就不用写了
  10. #platform:
  11. # os: linux
  12. # arch: amd64
  13. # 指定运行 runner,不需要
  14. # node:
  15. # name: pi-runner
  16. clone:
  17. depth: 1 # 定义git克隆的深度,这里只需要完整的克隆项目就行,之前的提交并不需要去克隆
  18. disable: false
  19. #######################################################
  20. ###### steps : https://drone.cool/pipeline/docker/syntax/steps/
  21. #######################################################
  22. # step为执行的步骤,drone的步骤每一步都是使用临时docker的容器来实现的,每一步docker容器执行完会被自动销毁,所以本配置中的第一个用的是docker的ssh镜像,可以用来执行指定容器的命令。settings中配置了ssh要登录的host、username等,由于我们把username的信息放入drone来配置,这样保证了这些敏感字段的安全
  23. #- name: run-python
  24. # image: appleboy/drone-ssh
  25. # settings:
  26. # host: 192.168.1.246
  27. # username:
  28. # from_secret: pi_user
  29. # password:
  30. # from_secret: pi_password
  31. # port: 22
  32. # environment:
  33. # GOOS: linux
  34. # command_timeout: 5m
  35. # script:
  36. # - echo success
  37. # - cd /home/pi/python/dnspod
  38. # - git pull
  39. # - bash run.sh
  40. # 条件
  41. # when:
  42. # branch:
  43. # - master
  44. # when:
  45. # status:
  46. # - failure
  47. # - success
  48. # failure: ignore 失败后如何?
  49. #failure: ""
  50. #failure: "fail"
  51. #failure: "fail-fast"
  52. #failure: "fast"
  53. #failure: "always" #
  54. #failure: "ignore" # 单个失败,不影响整个 pipline
  55. #
  56. # detach: true # 后台异步执行,并且忽略其结果
  57. #
  58. # privileged: true 给容器赋予访问主机权限
  59. #
  60. # 任意阶段任意命令返回非0,则全部按照失败终止
  61. #######################################################
  62. ###### service : https://drone.cool/pipeline/docker/syntax/services/
  63. #######################################################
  64. #######################################################
  65. ###### plugins : https://plugins.drone.io/
  66. #######################################################
  67. # 比如单侧单独用 redis,这里可以异步起动一个服务,pipline完成后关闭
  68. #steps:
  69. #- name: ping
  70. # image: redis
  71. # commands:
  72. # - redis-cli -h cache ping
  73. #services:
  74. #- name: cache
  75. # image: redis
  76. steps:
  77. - name: 编译
  78. image: maven:3-jdk-11
  79. pull: if-not-exists
  80. volumes:
  81. - name: mvnCache
  82. path: /root/.m2
  83. commands:
  84. - mvn compile -DskipTests=true -Dmaven.javadoc.skip=true -B -V
  85. - echo 'FINISHED!'
  86. #- name: build-java-app
  87. # image: docker.io/kameshsampath/drone-java-maven-plugin:v1.0.0
  88. # pull: if-not-exists
  89. ##################################### quality ##################################
  90. # Sonar 代码质量,包含 FindBugs、PMD等
  91. # Fortity 代码安全扫描 收费
  92. # pom 漏洞扫描
  93. # SonarQube https://github.com/mibexsoftware/sonar-bitbucket-plugin
  94. # OWASP ZAP
  95. # Brakeman
  96. # CodeClimate
  97. # Coverity
  98. # Klocwork
  99. # PMD
  100. # SonarLint
  101. # FindBugs 官网 15年停更
  102. # 代码规范:Alibaba Java Coding Guidelines、checkStyle
  103. # https://juejin.cn/post/6844904018297225224
  104. #- name: sonar-scan
  105. # image: newtmitch/sonar-scanner:4.0.0-alpine
  106. # environment:
  107. # SONAR_TOKEN:
  108. # from_secret: sonar_token
  109. # GITHUB_ACCESS_TOKEN_FOR_SONARQUBE:
  110. # from_secret: github_access_token_for_sonarqube
  111. # commands:
  112. # - >
  113. # sonar-scanner
  114. # -Dsonar.host.url=https://sonarqube.company-beta.com/
  115. # -Dsonar.login=?SONAR_TOKEN
  116. # -Dsonar.projectKey=smcp-service-BE
  117. # -Dsonar.projectName=smcp-service-BE
  118. # -Dsonar.projectVersion=${DRONE_BUILD_NUMBER}
  119. # -Dsonar.sources=src/main/java
  120. # -Dsonar.tests=src/test/java
  121. # -Dsonar.language=java
  122. # -Dsonar.java.coveragePlugin=jacoco
  123. # -Dsonar.modules=smcp-api,smcp-web
  124. # -Dsonar.java.binaries=target
  125. # -Dsonar.projectBaseDir=.
  126. # -Dsonar.analysis.mode=preview
  127. # -Dsonar.github.repository=Today_Group/SMCP-Service
  128. # -Dsonar.github.oauth=?GITHUB_ACCESS_TOKEN_FOR_SONARQUBE
  129. # -Dsonar.github.pullRequest=${DRONE_PULL_REQUEST}
  130. # -Dsonar.github.disableInlineComments=false
  131. # when:
  132. # event:
  133. # - pull_request
  134. # branch:
  135. # - develop
  136. #
  137. # # post sonarscan result back to git PR (not in preview mode)
  138. # - name: sonar-scan-feedback
  139. # image: newtmitch/sonar-scanner:4.0.0-alpine
  140. # environment:
  141. # SONAR_TOKEN:
  142. # from_secret: sonar_token
  143. # GITHUB_ACCESS_TOKEN_FOR_SONARQUBE:
  144. # from_secret: github_access_token_for_sonarqube
  145. # commands:
  146. # - >
  147. # sonar-scanner
  148. # -Dsonar.host.url=https://sonarqube.company-beta.com/
  149. # -Dsonar.login=?SONAR_TOKEN
  150. # -Dsonar.projectKey=smcp-service-BE
  151. # -Dsonar.projectName=smcp-service-BE
  152. # -Dsonar.projectVersion=${DRONE_BUILD_NUMBER}
  153. # -Dsonar.sources=src/main/java
  154. # -Dsonar.tests=src/test/java
  155. # -Dsonar.language=java
  156. # -Dsonar.java.coveragePlugin=jacoco
  157. # -Dsonar.modules=smcp-api,smcp-web
  158. # -Dsonar.java.binaries=target
  159. # -Dsonar.projectBaseDir=.
  160. # -Dsonar.analysis.gitRepo=Today_Group/SMCP-Service
  161. # -Dsonar.analysis.pullRequest=${DRONE_PULL_REQUEST}
  162. # when:
  163. # event:
  164. # - pull_request
  165. # branch:
  166. # - develop
  167. ##################################### NOTIFY ####################################
  168. - name: 钉钉通知
  169. image: guoxudongdocker/drone-dingtalk
  170. settings:
  171. token: 178f267b9b16b168e0a0afb223b3d41f3a58e62180ab5288aa576db02965dd72
  172. type: markdown
  173. #5f6c32b36e771df227b1ccb8898325158e12d851ae61982d1ec225a1aa58e251
  174. - name: dingtalk
  175. image: lddsb/drone-dingtalk-message
  176. settings:
  177. token: 178f267b9b16b168e0a0afb223b3d41f3a58e62180ab5288aa576db02965dd72
  178. type: markdown
  179. success_color: 008000
  180. failure_color: FF0000
  181. success_pic: http://82.157.141.169:16666/avatars/1
  182. msg_at_mobiles: 15858193327
  183. #- name: email-notify
  184. # image: drillster/drone-email
  185. # settings:
  186. # host: smtp.some-server.com
  187. # username: foo
  188. # password: bar
  189. # from: drone@your-domain.com
  190. - name: wechat notify
  191. image: lizheming/drone-wechat
  192. settings:
  193. corpid: ww01cb42e24566126d
  194. corp_secret: un_CtWqThxc11MKWPK5SNWsFEgU9MkI7MIjvyvV9KjA
  195. agent_id: 1000002
  196. to_tag: ${DRONE_REPO_NAME}
  197. msg_url: ${DRONE_BUILD_LINK}
  198. safe: 1
  199. btn_txt: more
  200. title: ${DRONE_REPO_NAME}
  201. message: >
  202. {%if success %}
  203. build {{build.number}} succeeded. Good job.
  204. {% else %}
  205. build {{build.number}} failed. Fix me please.
  206. {% endif %}
  207. - name: wechat
  208. image: clem109/drone-wechat
  209. settings:
  210. corpid: ww01cb42e24566126d
  211. corp_secret: un_CtWqThxc11MKWPK5SNWsFEgU9MkI7MIjvyvV9KjA
  212. agent_id: 1000002
  213. title: ${DRONE_REPO_NAME}
  214. description: "Build Number: ${DRONE_BUILD_NUMBER} failed. ${DRONE_COMMIT_AUTHOR} please fix. Check the results here: ${DRONE_BUILD_LINK} "
  215. msg_url: ${DRONE_BUILD_LINK}
  216. btn_txt: bt
  217. volumes:
  218. - name: mvnCache
  219. host:
  220. path: /tmp/cache/.m2
  221. trigger:
  222. branch:
  223. - master
  224. event:
  225. - push