.drone.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. ##################### functions start ###########################
  2. build_config: &build_config
  3. privileged: true
  4. image: dongcj/centos7
  5. volumes:
  6. - /var/run/docker.sock:/var/run/docker.sock
  7. repo_config: &repo_config
  8. image: plugins/docker
  9. repo: tyn.ar3qvx.com/cdn/evlss
  10. registry: tyn.ar3qvx.com
  11. secrets: [ DOCKER_USERNAME, DOCKER_PASSWORD ]
  12. deploy_config: &deploy_config
  13. image: peloton/drone-rancher
  14. repo: tyn.ar3qvx.com/cdn/evlss
  15. service: cdn/evlss
  16. ##################### main start ###############################
  17. pipeline:
  18. # 1. notify
  19. notify_begin_slack:
  20. image: plugins/slack
  21. webhook: https://hooks.slack.com/services/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
  22. channel: general
  23. username: drone-bot
  24. template: "<{{build.link}}|Deployment #{{build.number}} started> on <http://tyn.ar3qvx.com:3000/{{repo.owner}}/{{repo.name}}/tree/{{build.branch}}|{{repo.name}}:{{build.branch}}> by: {{build.author}}"
  25. when:
  26. branch: [ master, staging ]
  27. ##################### build start ###############################
  28. # 2.1 build binary
  29. build:
  30. <<: *build_config
  31. commands:
  32. - echo "do something"
  33. - sleep 30
  34. - echo "build success"
  35. when:
  36. branch:
  37. - develop
  38. - master
  39. # build_release:
  40. # <<: *build_config
  41. # when:
  42. # event: tag
  43. ##################### build & publish docker image ##############
  44. # 3. build docker images
  45. build_docker_image:
  46. image: plugins/docker
  47. commands:
  48. - make all
  49. # 4. publish images to test registry(tag: dev)
  50. # drone deploy octocat/hello-world 24 staging
  51. publish_develop:
  52. <<: *repo_config
  53. tag:
  54. - dev
  55. when:
  56. branch: develop
  57. event: push
  58. # 4. publish images to test registry
  59. # drone deploy octocat/hello-world 24 staging
  60. publish_latest:
  61. <<: *build_config
  62. tag:
  63. - latest
  64. - v0.4
  65. when:
  66. branch: master
  67. event: push
  68. # 4. publish image to test registry
  69. # drone deploy octocat/hello-world 24 staging
  70. publish_release:
  71. <<: *build_config
  72. tag:
  73. - "${DRONE_TAG}"
  74. when:
  75. event: tag
  76. ################### deploy in test env ##########################
  77. # 5. deploy to rancher(test env)
  78. publish_to_test_env:
  79. <<: *deploy_config
  80. url: http://tyn.ar3qvx.com:8080
  81. access_key: ${RANCHER_ACCESS_KEY_TEST}
  82. secret_key: ${RANCHER_SECRET_KEY_TEST}
  83. docker_image: tyn.ar3qvx.com/cdn/evlss
  84. # start new container before stopping old one, default to true
  85. start_first: false
  86. # auto confirm service upgrade
  87. confirm: true
  88. timeout: 240
  89. # batch size for the service upgrade
  90. batch_size: 5
  91. ##################### test in test env ##########################
  92. # test in rancher
  93. test_stage:
  94. image: dongcj/webshell
  95. commands:
  96. - sleep 20
  97. ##################### deploy to production ######################
  98. # test in rancher
  99. test_stage:
  100. image: dongcj/webshell
  101. commands:
  102. - sleep 20
  103. ##################### notify start ##############################
  104. notify_test_stage:
  105. image: plugins/slack
  106. webhook: https://hooks.slack.com/services/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
  107. channel: general
  108. username: drone-bot
  109. when:
  110. branch: [ master, staging ]
  111. status: [ success ]
  112. template: "<{{build.link}}|Deployment #{{build.number}} success> on <http://http://tyn.ar3qvx.com:3000/{{repo.owner}}/{{repo.name}}/tree/{{build.branch}}|{{repo.name}}:{{build.branch}}> by: {{build.author}}"
  113. notify_end_slack:
  114. image: plugins/slack
  115. webhook: https://hooks.slack.com/services/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
  116. channel: general
  117. username: drone-bot
  118. when:
  119. branch: [ master, staging ]
  120. status: [ success, failure ]
  121. template: "<{{build.link}}|Deployment #{{build.number}} stop> on <http://http://tyn.ar3qvx.com:3000/{{repo.owner}}/{{repo.name}}/tree/{{build.branch}}|{{repo.name}}:{{build.branch}}> by: {{build.author}}"
  122. notify_end_email:
  123. image: drillster/drone-email
  124. host: smtp.mxhichina.com
  125. skip_verify: false
  126. username: admin@dongcj.com
  127. password: Dcj85509336
  128. from: drone@svicloud.com
  129. recipients: [ dongchaojun@svi-tech.com.cn, admin@svicloud.com ]
  130. recipients_only: false
  131. when:
  132. status: [ changed, failure ]