.drone.yml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. kind: pipeline
  2. type: docker
  3. name: 自动部署
  4. clone:
  5. disable: true # 禁用自带clone
  6. steps:
  7. - name: 镜像打包
  8. pull: if-not-exists
  9. image: plugins/docker
  10. settings:
  11. #dockerfile: ./docker/ 默认根目录
  12. repo: harbor.sxidc.com/ywzx/${DRONE_REPO_NAME//_/-}
  13. registry: harbor.sxidc.com
  14. tags: ${DRONE_COMMIT_BRANCH/master/latest}
  15. username:
  16. from_secret: harbor_username
  17. password:
  18. from_secret: harbor_password
  19. - name: ssh-commands
  20. pull: if-not-exists
  21. image: appleboy/drone-ssh:1.5.7
  22. settings:
  23. host: test_host
  24. username: test_user
  25. password:
  26. # 从drone仓库配置中秘密空间读取密码
  27. from_secret: test_pwd
  28. port: 22
  29. script:
  30. - echo =======暂停容器=======
  31. - docker stop `docker ps -a | grep kingdee_big_screen | awk '{print $1}' `
  32. - echo =======暂停旧容器和镜像=======
  33. - docker rm -f `docker ps -a | grep kingdee_big_screen | awk '{print $1}' `
  34. - docker rmi `docker images | grep harbor.sxidc.com/fs/kingdee_big_screen | awk '{print $3}' `
  35. - echo =======开始部署应用=======
  36. - docker run -d -p 10003:80 --name kingdee_big_screen harbor.sxidc.com/fs/kingdee_big_screen
  37. - echo =======清理构建文件,建议保留=======
  38. - echo =======部署成功=======
  39. trigger:
  40. branch:
  41. - master
  42. event:
  43. - promote