.drone.yml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  1. #########################################################################################################
  2. # 1.打包构建lhb-gateway
  3. kind: pipeline
  4. type: docker
  5. name: lhb-gateway-prod
  6. volumes:
  7. - name: mvn_repo
  8. host:
  9. path: /home/ABServer/cache/mvn_repo
  10. - name: mvn_config
  11. host:
  12. path: /home/ABServer/config/mvn
  13. - name: build-artifacts
  14. host:
  15. path: /home/ABServer/webroot/lhb-gateway
  16. - name: dockerfile-source
  17. host:
  18. path: /home/ABServer/config/docker
  19. - name: timezone
  20. host:
  21. path: /etc/localtime
  22. - name: docker-socket
  23. host:
  24. path: /var/run/docker.sock
  25. clone:
  26. disable: false
  27. steps:
  28. # 阶段1: Maven构建
  29. - name: build-project
  30. image: maven:3.9.4-amazoncorretto-17
  31. pull: if-not-exists
  32. volumes:
  33. - name: mvn_repo
  34. path: /usr/share/maven/repo
  35. - name: mvn_config
  36. path: /usr/share/maven/conf
  37. commands:
  38. - mvn clean package -Dmaven.test.skip=true -P prod
  39. - echo "===== 构建产物验证 ====="
  40. - ls -l lhb-gateway/target/*.jar
  41. - '[ -d lhb-gateway/target/lib ] || exit 1'
  42. - '[ -d lhb-gateway/target/config ] || exit 1'
  43. # 阶段2: 准备Docker上下文(关键修正部分)
  44. - name: prepare-docker-context
  45. image: alpine:3.21.3
  46. depends_on: [ build-project ]
  47. volumes:
  48. - name: build-artifacts
  49. path: /context
  50. - name: dockerfile-source
  51. path: /dockerfiles
  52. commands:
  53. - rm -rf /context/*
  54. - cp -v lhb-gateway/target/*.jar /context/
  55. - cp -rv lhb-gateway/target/lib /context/
  56. - cp -rv lhb-gateway/target/config /context/
  57. - cp /dockerfiles/template-min.dockerfile /context/Dockerfile
  58. - sed -i 's/{Xms}/1024m/g' /context/Dockerfile
  59. - sed -i 's/{Xmx}/1024m/g' /context/Dockerfile
  60. - sed -i 's/{ImageName}/lhb-gateway/g' /context/Dockerfile
  61. - echo -e "*\n!*.jar\n!lib/\n!config/\n!Dockerfile" > /context/.dockerignore
  62. - ls -alR /context
  63. # 阶段3: 构建并推送镜像
  64. - name: docker-build-push
  65. image: docker:24.0-cli
  66. depends_on: [ prepare-docker-context ]
  67. volumes:
  68. - name: build-artifacts
  69. path: /context
  70. - name: timezone
  71. path: /etc/localtime
  72. - name: docker-socket
  73. path: /var/run/docker.sock
  74. environment:
  75. HARBOR_USER:
  76. from_secret: harbor_robot
  77. HARBOR_PASS:
  78. from_secret: harbor_token
  79. commands:
  80. - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
  81. - cd /context
  82. - TAG=$(date +%Y%m%d%H%M%S)
  83. - docker build -t "harbor.kexiaoshuang.com/laihaoba/lhb-gateway:$TAG" .
  84. - docker push "harbor.kexiaoshuang.com/laihaoba/lhb-gateway:$TAG"
  85. - docker rmi "harbor.kexiaoshuang.com/laihaoba/lhb-gateway:$TAG"
  86. trigger:
  87. event: [ push ]
  88. branch: [ release-gateway ]
  89. #########################################################################################################
  90. #2.打包构建lhb-quartz-prod
  91. ---
  92. kind: pipeline
  93. type: docker
  94. name: lhb-quartz-prod
  95. volumes:
  96. - name: mvn_repo
  97. host:
  98. path: /home/ABServer/cache/mvn_repo
  99. - name: mvn_config
  100. host:
  101. path: /home/ABServer/config/mvn
  102. - name: build-artifacts
  103. host:
  104. path: /home/ABServer/webroot/lhb-quartz
  105. - name: dockerfile-source
  106. host:
  107. path: /home/ABServer/config/docker
  108. - name: timezone
  109. host:
  110. path: /etc/localtime
  111. - name: docker-socket
  112. host:
  113. path: /var/run/docker.sock
  114. clone:
  115. disable: false
  116. steps:
  117. # 阶段1: Maven构建
  118. - name: build-project
  119. image: maven:3.9.4-amazoncorretto-17
  120. pull: if-not-exists
  121. volumes:
  122. - name: mvn_repo
  123. path: /usr/share/maven/repo
  124. - name: mvn_config
  125. path: /usr/share/maven/conf
  126. commands:
  127. - mvn clean package -Dmaven.test.skip=true -P prod
  128. - echo "===== 构建产物验证 ====="
  129. - ls -l lhb-quartz/target/*.jar
  130. - '[ -d lhb-quartz/target/lib ] || exit 1'
  131. - '[ -d lhb-quartz/target/config ] || exit 1'
  132. # 阶段2: 准备Docker上下文(关键修正部分)
  133. - name: prepare-docker-context
  134. image: alpine:3.21.3
  135. depends_on: [ build-project ]
  136. volumes:
  137. - name: build-artifacts
  138. path: /context
  139. - name: dockerfile-source
  140. path: /dockerfiles
  141. commands:
  142. - rm -rf /context/*
  143. - cp -v lhb-quartz/target/*.jar /context/
  144. - cp -rv lhb-quartz/target/lib /context/
  145. - cp -rv lhb-quartz/target/config /context/
  146. - cp /dockerfiles/template-min.dockerfile /context/Dockerfile
  147. - sed -i 's/{Xms}/256m/g' /context/Dockerfile
  148. - sed -i 's/{Xmx}/256m/g' /context/Dockerfile
  149. - sed -i 's/{ImageName}/lhb-quartz/g' /context/Dockerfile
  150. - echo -e "*\n!*.jar\n!lib/\n!config/\n!Dockerfile" > /context/.dockerignore
  151. - ls -alR /context
  152. # 阶段3: 构建并推送镜像
  153. - name: docker-build-push
  154. image: docker:24.0-cli
  155. depends_on: [ prepare-docker-context ]
  156. volumes:
  157. - name: build-artifacts
  158. path: /context
  159. - name: timezone
  160. path: /etc/localtime
  161. - name: docker-socket
  162. path: /var/run/docker.sock
  163. environment:
  164. HARBOR_USER:
  165. from_secret: harbor_robot
  166. HARBOR_PASS:
  167. from_secret: harbor_token
  168. commands:
  169. - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
  170. - cd /context
  171. - TAG=$(date +%Y%m%d%H%M%S)
  172. - docker build -t "harbor.kexiaoshuang.com/laihaoba/lhb-quartz:$TAG" .
  173. - docker push "harbor.kexiaoshuang.com/laihaoba/lhb-quartz:$TAG"
  174. - docker rmi "harbor.kexiaoshuang.com/laihaoba/lhb-quartz:$TAG"
  175. trigger:
  176. event: [ push ]
  177. branch: [ release-quartz ]
  178. ###########################################################################################################
  179. # 3.打包构建lhb-system-prod
  180. ---
  181. kind: pipeline
  182. type: docker
  183. name: lhb-system-prod
  184. # 定义所有 Volume 映射
  185. volumes:
  186. - name: mvn_repo
  187. host:
  188. path: /home/ABServer/cache/mvn_repo
  189. - name: mvn_config
  190. host:
  191. path: /home/ABServer/config/mvn
  192. - name: build-artifacts # 构建产物临时目录
  193. host:
  194. path: /home/ABServer/webroot/lhb-system
  195. - name: dockerfile-source
  196. host:
  197. path: /home/ABServer/config/docker
  198. - name: timezone
  199. host:
  200. path: /etc/localtime
  201. - name: docker-socket
  202. host:
  203. path: /var/run/docker.sock
  204. clone:
  205. disable: false
  206. steps:
  207. # 阶段1: Maven 构建
  208. - name: build-project
  209. image: maven:3.9.4-amazoncorretto-17
  210. pull: if-not-exists
  211. volumes:
  212. - name: mvn_repo
  213. path: /usr/share/maven/repo
  214. - name: mvn_config
  215. path: /usr/share/maven/conf
  216. commands:
  217. - mvn clean package -Dmaven.test.skip=true -P prod
  218. - echo "===== 构建产物生成验证 ====="
  219. - ls -l lhb-system/lhb-system-biz/target/*.jar
  220. - '[ -d lhb-system/lhb-system-biz/target/lib ] || exit 1'
  221. - '[ -d lhb-system/lhb-system-biz/target/config ] || exit 1'
  222. # 阶段2: 准备 Docker 构建上下文
  223. - name: prepare-docker-context
  224. image: alpine:3.21.3
  225. depends_on: [ build-project ]
  226. volumes:
  227. - name: build-artifacts
  228. path: /context
  229. - name: dockerfile-source
  230. path: /dockerfiles
  231. commands:
  232. - rm -rf /context/*
  233. - cp -v lhb-system/lhb-system-biz/target/*.jar /context/
  234. - cp -rv lhb-system/lhb-system-biz/target/lib /context/
  235. - cp -rv lhb-system/lhb-system-biz/target/config /context/
  236. - cp /dockerfiles/template-biz-min.dockerfile /context/Dockerfile
  237. - sed -i 's/{Xms}/512m/g' /context/Dockerfile
  238. - sed -i 's/{Xmx}/512m/g' /context/Dockerfile
  239. - sed -i 's/{ImageName}/lhb-system/g' /context/Dockerfile
  240. - echo -e "*\n!*.jar\n!lib/\n!config/\n!Dockerfile" > /context/.dockerignore
  241. - echo "===== 构建上下文文件列表 ====="
  242. - ls -laR /context
  243. # 阶段3: 构建并推送镜像
  244. - name: docker-build-push
  245. image: docker:24.0-cli
  246. depends_on: [ prepare-docker-context ]
  247. volumes:
  248. - name: build-artifacts
  249. path: /context
  250. - name: timezone
  251. path: /etc/localtime
  252. - name: docker-socket
  253. path: /var/run/docker.sock
  254. environment:
  255. HARBOR_USER:
  256. from_secret: harbor_robot
  257. HARBOR_PASS:
  258. from_secret: harbor_token
  259. commands:
  260. - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
  261. - cd /context
  262. - TAG=$(date +%Y%m%d%H%M%S)
  263. - docker build -t "harbor.kexiaoshuang.com/laihaoba/lhb-system:$TAG" .
  264. - docker push "harbor.kexiaoshuang.com/laihaoba/lhb-system:$TAG"
  265. - docker rmi "harbor.kexiaoshuang.com/laihaoba/lhb-system:$TAG"
  266. trigger:
  267. event: [ push ]
  268. branch: [ release-system ]
  269. ##########################################################################################################
  270. # 4.打包构建lhb-basic
  271. ---
  272. kind: pipeline
  273. type: docker
  274. name: lhb-basic-prod
  275. # 定义所有 Volume 映射
  276. volumes:
  277. - name: mvn_repo
  278. host:
  279. path: /home/ABServer/cache/mvn_repo
  280. - name: mvn_config
  281. host:
  282. path: /home/ABServer/config/mvn
  283. - name: build-artifacts # 构建产物临时目录
  284. host:
  285. path: /home/ABServer/webroot/lhb-basic
  286. - name: dockerfile-source
  287. host:
  288. path: /home/ABServer/config/docker
  289. - name: timezone
  290. host:
  291. path: /etc/localtime
  292. - name: docker-socket
  293. host:
  294. path: /var/run/docker.sock
  295. clone:
  296. disable: false
  297. steps:
  298. # 阶段1: Maven 构建
  299. - name: build-project
  300. image: maven:3.9.4-amazoncorretto-17
  301. pull: if-not-exists
  302. volumes:
  303. - name: mvn_repo
  304. path: /usr/share/maven/repo
  305. - name: mvn_config
  306. path: /usr/share/maven/conf
  307. commands:
  308. - mvn clean package -Dmaven.test.skip=true -P prod
  309. - echo "===== 构建产物生成验证 ====="
  310. - ls -l lhb-basic/lhb-basic-biz/target/*.jar
  311. - '[ -d lhb-basic/lhb-basic-biz/target/lib ] || exit 1'
  312. - '[ -d lhb-basic/lhb-basic-biz/target/config ] || exit 1'
  313. # 阶段2: 准备 Docker 构建上下文
  314. - name: prepare-docker-context
  315. image: alpine:3.21.3
  316. depends_on: [ build-project ]
  317. volumes:
  318. - name: build-artifacts
  319. path: /context
  320. - name: dockerfile-source
  321. path: /dockerfiles
  322. commands:
  323. - rm -rf /context/*
  324. - cp -v lhb-basic/lhb-basic-biz/target/*.jar /context/
  325. - cp -rv lhb-basic/lhb-basic-biz/target/lib /context/
  326. - cp -rv lhb-basic/lhb-basic-biz/target/config /context/
  327. - cp /dockerfiles/template-biz-min.dockerfile /context/Dockerfile
  328. - sed -i 's/{Xms}/512m/g' /context/Dockerfile
  329. - sed -i 's/{Xmx}/512m/g' /context/Dockerfile
  330. - sed -i 's/{ImageName}/lhb-basic/g' /context/Dockerfile
  331. - echo -e "*\n!*.jar\n!lib/\n!config/\n!Dockerfile" > /context/.dockerignore
  332. - echo "===== 构建上下文文件列表 ====="
  333. - ls -laR /context
  334. # 阶段3: 构建并推送镜像
  335. - name: docker-build-push
  336. image: docker:24.0-cli
  337. depends_on: [ prepare-docker-context ]
  338. volumes:
  339. - name: build-artifacts
  340. path: /context
  341. - name: timezone
  342. path: /etc/localtime
  343. - name: docker-socket
  344. path: /var/run/docker.sock
  345. environment:
  346. HARBOR_USER:
  347. from_secret: harbor_robot
  348. HARBOR_PASS:
  349. from_secret: harbor_token
  350. commands:
  351. - docker login -u "$HARBOR_USER" -p "$HARBOR_PASS" harbor.kexiaoshuang.com
  352. - cd /context
  353. - TAG=$(date +%Y%m%d%H%M%S)
  354. - docker build -t "harbor.kexiaoshuang.com/laihaoba/lhb-basic:$TAG" .
  355. - docker push "harbor.kexiaoshuang.com/laihaoba/lhb-basic:$TAG"
  356. - docker rmi "harbor.kexiaoshuang.com/laihaoba/lhb-basic:$TAG"
  357. trigger:
  358. event: [ push ]
  359. branch: [ release-basic ]
  360. #############################################################################################
  361. # 测试分支打包
  362. # 1.lhb-gateway-test
  363. ---
  364. kind: pipeline
  365. type: docker
  366. name: lhb-gateway-test
  367. volumes: # 声明数据卷
  368. - name: mvn_repo # 数据卷名称
  369. # Host Volume, 挂载到宿主机上的卷轴
  370. host:
  371. # 宿主机的绝对路径
  372. path: /home/ABServer/cache/mvn_repo
  373. - name: mvn_config
  374. host:
  375. path: /home/ABServer/config/mvn/
  376. - name: targetDir
  377. host:
  378. path: /lhb-gateway
  379. clone:
  380. disable: false # 启用代码拉取
  381. steps:
  382. - name: build-project
  383. image: maven:3.9.4-amazoncorretto-17
  384. pull: if-not-exists
  385. depends_on: [clone] # 依赖的步骤
  386. volumes: # 挂载数据卷
  387. - name: mvn_repo # 数据卷名称
  388. path: /usr/share/maven/repo # 容器内目录 绝对路径
  389. - name: targetDir
  390. path: /drone/src/dist/
  391. - name: mvn_config
  392. path: /usr/share/maven/conf/
  393. commands: # 执行命令
  394. - rm -rf /drone/src/dist/*
  395. - mvn clean package -Dmaven.test.skip=true -P test
  396. - cp /drone/src/lhb-gateway/target/*.jar /drone/src/dist/ && cp -r /drone/src/lhb-gateway/target/lib /drone/src/dist/ && cp -r /drone/src/lhb-gateway/target/config /drone/src/dist/ # 复制文件
  397. when:
  398. status:
  399. - success # 当前步骤成功时执行
  400. - name: scp-project
  401. image: appleboy/drone-scp
  402. pull: if-not-exists
  403. depends_on: [build-project] # 依赖的步骤
  404. volumes: # 挂载数据卷
  405. - name: targetDir # 数据卷名称
  406. path: /lhb-gateway # 容器内目录 绝对路径
  407. settings:
  408. host:
  409. from_secret: host
  410. username:
  411. from_secret: username
  412. password:
  413. from_secret: userpwd
  414. port: 22
  415. command_timeout: 2m
  416. target: /home/ABServer/deploy-ready/
  417. source:
  418. - echo ====开始拷贝=======
  419. - /lhb-gateway/*.jar
  420. - /lhb-gateway/lib
  421. - /lhb-gateway/config
  422. - echo ====结束拷贝=======
  423. when:
  424. status:
  425. - success # 当前步骤成功时执行
  426. - name: deploy-project
  427. image: appleboy/drone-ssh
  428. pull: if-not-exists
  429. depends_on: [scp-project] # 依赖的步骤
  430. settings:
  431. host:
  432. from_secret: host
  433. username:
  434. from_secret: username
  435. password:
  436. from_secret: userpwd
  437. port: 22
  438. command_timeout: 2m
  439. script:
  440. - echo ====开始部署=======
  441. - cd /home/ABServer/
  442. - cp -r /home/ABServer/deploy-ready/lhb-gateway /home/ABServer/webroot/
  443. - docker stop lhb-gateway && docker rm lhb-gateway && docker-compose up -d lhb-gateway
  444. # - docker restart nodeServer1
  445. - echo ====部署成功=======
  446. trigger:
  447. branch:
  448. include:
  449. - test-gateway
  450. event:
  451. include:
  452. - pull_request
  453. - push
  454. ############################################################################################
  455. ---
  456. kind: pipeline
  457. type: docker
  458. name: lhb-quartz-test
  459. volumes: # 声明数据卷
  460. - name: mvn_repo # 数据卷名称
  461. # Host Volume, 挂载到宿主机上的卷轴
  462. host:
  463. # 宿主机的绝对路径
  464. path: /home/ABServer/cache/mvn_repo
  465. - name: mvn_config
  466. host:
  467. path: /home/ABServer/config/mvn/
  468. - name: targetDir
  469. host:
  470. path: /lhb-quartz
  471. clone:
  472. disable: false # 启用代码拉取
  473. steps:
  474. - name: build-project
  475. image: maven:3.9.4-amazoncorretto-17
  476. pull: if-not-exists
  477. depends_on: [clone] # 依赖的步骤
  478. volumes: # 挂载数据卷
  479. - name: mvn_repo # 数据卷名称
  480. path: /usr/share/maven/repo # 容器内目录 绝对路径
  481. - name: targetDir
  482. path: /drone/src/dist/
  483. - name: mvn_config
  484. path: /usr/share/maven/conf/
  485. commands: # 执行命令
  486. - rm -rf /drone/src/dist/*
  487. - mvn clean package -Dmaven.test.skip=true -P test
  488. - cp /drone/src/lhb-quartz/target/*.jar /drone/src/dist/ && cp -r /drone/src/lhb-quartz/target/lib /drone/src/dist/ && cp -r /drone/src/lhb-quartz/target/config /drone/src/dist/ # 复制文件
  489. when:
  490. status:
  491. - success # 当前步骤成功时执行
  492. - name: scp-project
  493. image: appleboy/drone-scp
  494. pull: if-not-exists
  495. depends_on: [build-project] # 依赖的步骤
  496. volumes: # 挂载数据卷
  497. - name: targetDir # 数据卷名称
  498. path: /lhb-quartz # 容器内目录 绝对路径
  499. settings:
  500. host:
  501. from_secret: host
  502. username:
  503. from_secret: username
  504. password:
  505. from_secret: userpwd
  506. port: 22
  507. command_timeout: 2m
  508. target: /home/ABServer/deploy-ready/
  509. source:
  510. - echo ====开始拷贝=======
  511. - /lhb-quartz/*.jar
  512. - /lhb-quartz/lib
  513. - /lhb-quartz/config
  514. - echo ====结束拷贝=======
  515. when:
  516. status:
  517. - success # 当前步骤成功时执行
  518. - name: deploy-project
  519. image: appleboy/drone-ssh
  520. pull: if-not-exists
  521. depends_on: [scp-project] # 依赖的步骤
  522. settings:
  523. host:
  524. from_secret: host
  525. username:
  526. from_secret: username
  527. password:
  528. from_secret: userpwd
  529. port: 22
  530. command_timeout: 2m
  531. script:
  532. - echo ====开始部署=======
  533. - cd /home/ABServer/
  534. - rm -rf /home/ABServer/webroot/lhb-quartz/*
  535. - cp -r /home/ABServer/deploy-ready/lhb-quartz /home/ABServer/webroot/
  536. - docker restart lhb-quartz
  537. - rm -rf /home/ABServer/deploy-ready/lhb-quartz/*
  538. # - docker restart nodeServer1
  539. - echo ====部署成功=======
  540. trigger:
  541. branch:
  542. include:
  543. - test-quartz
  544. event:
  545. include:
  546. - pull_request
  547. - push
  548. ############################################################################################
  549. ---
  550. kind: pipeline
  551. type: docker
  552. name: lhb-system-test
  553. volumes: # 声明数据卷
  554. - name: mvn_repo # 数据卷名称
  555. # Host Volume, 挂载到宿主机上的卷轴
  556. host:
  557. # 宿主机的绝对路径
  558. path: /home/ABServer/cache/mvn_repo
  559. - name: mvn_config
  560. host:
  561. path: /home/ABServer/config/mvn/
  562. - name: targetDir
  563. host:
  564. path: /lhb-system
  565. clone:
  566. disable: false # 启用代码拉取
  567. steps:
  568. - name: build-project
  569. image: maven:3.9.4-amazoncorretto-17
  570. pull: if-not-exists
  571. depends_on: [clone] # 依赖的步骤
  572. volumes: # 挂载数据卷
  573. - name: mvn_repo # 数据卷名称
  574. path: /usr/share/maven/repo # 容器内目录 绝对路径
  575. - name: targetDir
  576. path: /drone/src/lhb/dist/
  577. - name: mvn_config
  578. path: /usr/share/maven/conf/
  579. commands: # 执行命令
  580. - rm -rf /drone/src/lhb/dist/*
  581. - mvn clean package -Dmaven.test.skip=true -P test
  582. - cp /drone/src/lhb-system/lhb-system-biz/target/*.jar /drone/src/lhb/dist/ && cp -r /drone/src/lhb-system/lhb-system-biz/target/lib /drone/src/lhb/dist/ && cp -r /drone/src/lhb-system/lhb-system-biz/target/config /drone/src/lhb/dist/ # 复制文件
  583. when:
  584. status:
  585. - success # 当前步骤成功时执行
  586. - name: scp-project
  587. image: appleboy/drone-scp
  588. pull: if-not-exists
  589. depends_on: [build-project] # 依赖的步骤
  590. volumes: # 挂载数据卷
  591. - name: targetDir # 数据卷名称
  592. path: /lhb-system # 容器内目录 绝对路径
  593. settings:
  594. host:
  595. from_secret: host
  596. username:
  597. from_secret: username
  598. password:
  599. from_secret: userpwd
  600. port: 22
  601. command_timeout: 2m
  602. target: /home/ABServer/deploy-ready/
  603. source:
  604. - echo ====开始拷贝=======
  605. - /lhb-system/*.jar
  606. - /lhb-system/lib
  607. - /lhb-system/config
  608. - echo ====结束拷贝=======
  609. when:
  610. status:
  611. - success # 当前步骤成功时执行
  612. - name: deploy-project
  613. image: appleboy/drone-ssh
  614. pull: if-not-exists
  615. depends_on: [scp-project] # 依赖的步骤
  616. settings:
  617. host:
  618. from_secret: host
  619. username:
  620. from_secret: username
  621. password:
  622. from_secret: userpwd
  623. port: 22
  624. command_timeout: 2m
  625. script:
  626. - echo ====开始部署=======
  627. - cd /home/ABServer/
  628. - rm -rf /home/ABServer/webroot/lhb-system/*
  629. - cp -r /home/ABServer/deploy-ready/lhb-system /home/ABServer/webroot/
  630. - docker stop lhb-system && docker rm lhb-system && docker-compose up -d lhb-system
  631. - rm -rf /home/ABServer/deploy-ready/lhb-system/*
  632. # - docker restart nodeServer1
  633. - echo ====部署成功=======
  634. trigger:
  635. branch:
  636. include:
  637. - test-system
  638. event:
  639. include:
  640. - pull_request
  641. - push
  642. ############################################################################################
  643. ---
  644. kind: pipeline
  645. type: docker
  646. name: lhb-basic-test
  647. volumes: # 声明数据卷
  648. - name: mvn_repo # 数据卷名称
  649. # Host Volume, 挂载到宿主机上的卷轴
  650. host:
  651. # 宿主机的绝对路径
  652. path: /home/ABServer/cache/mvn_repo
  653. - name: mvn_config
  654. host:
  655. path: /home/ABServer/config/mvn/
  656. - name: targetDir
  657. host:
  658. path: /lhb-basic
  659. clone:
  660. disable: false # 启用代码拉取
  661. steps:
  662. - name: build-project
  663. image: maven:3.9.4-amazoncorretto-17
  664. pull: if-not-exists
  665. depends_on: [clone] # 依赖的步骤
  666. volumes: # 挂载数据卷
  667. - name: mvn_repo # 数据卷名称
  668. path: /usr/share/maven/repo # 容器内目录 绝对路径
  669. - name: targetDir
  670. path: /drone/src/lhb/dist/
  671. - name: mvn_config
  672. path: /usr/share/maven/conf/
  673. commands: # 执行命令
  674. - rm -rf /drone/src/lhb/dist/*
  675. - mvn clean package -Dmaven.test.skip=true -P test
  676. - cp /drone/src/lhb-basic/lhb-basic-biz/target/*.jar /drone/src/lhb/dist/ && cp -r /drone/src/lhb-basic/lhb-basic-biz/target/lib /drone/src/lhb/dist/ && cp -r /drone/src/lhb-basic/lhb-basic-biz/target/config /drone/src/lhb/dist/ # 复制文件
  677. when:
  678. status:
  679. - success # 当前步骤成功时执行
  680. - name: scp-project
  681. image: appleboy/drone-scp
  682. pull: if-not-exists
  683. depends_on: [build-project] # 依赖的步骤
  684. volumes: # 挂载数据卷
  685. - name: targetDir # 数据卷名称
  686. path: /lhb-basic # 容器内目录 绝对路径
  687. settings:
  688. host:
  689. from_secret: host
  690. username:
  691. from_secret: username
  692. password:
  693. from_secret: userpwd
  694. port: 22
  695. command_timeout: 2m
  696. target: /home/ABServer/deploy-ready/
  697. source:
  698. - echo ====开始拷贝=======
  699. - /lhb-basic/*.jar
  700. - /lhb-basic/lib
  701. - /lhb-basic/config
  702. - echo ====结束拷贝=======
  703. when:
  704. status:
  705. - success # 当前步骤成功时执行
  706. - name: deploy-project
  707. image: appleboy/drone-ssh
  708. pull: if-not-exists
  709. depends_on: [scp-project] # 依赖的步骤
  710. settings:
  711. host:
  712. from_secret: host
  713. username:
  714. from_secret: username
  715. password:
  716. from_secret: userpwd
  717. port: 22
  718. command_timeout: 2m
  719. script:
  720. - echo ====开始部署=======
  721. - cd /home/ABServer/
  722. - rm -rf /home/ABServer/webroot/lhb-basic/*
  723. - cp -r /home/ABServer/deploy-ready/lhb-basic /home/ABServer/webroot/
  724. - docker stop lhb-basic && docker rm lhb-basic && docker-compose up -d lhb-basic
  725. - rm -rf /home/ABServer/deploy-ready/lhb-basic/*
  726. # - docker restart nodeServer1
  727. - echo ====部署成功=======
  728. trigger:
  729. branch:
  730. include:
  731. - test-basic
  732. event:
  733. include:
  734. - pull_request
  735. - push