##################### functions start ########################### build_config: &build_config privileged: true image: dongcj/centos7 volumes: - /var/run/docker.sock:/var/run/docker.sock repo_config: &repo_config image: plugins/docker repo: tyn.ar3qvx.com/cdn/evlss registry: tyn.ar3qvx.com secrets: [ DOCKER_USERNAME, DOCKER_PASSWORD ] deploy_config: &deploy_config image: peloton/drone-rancher repo: tyn.ar3qvx.com/cdn/evlss service: cdn/evlss ##################### main start ############################### pipeline: # 1. notify notify_begin_slack: image: plugins/slack webhook: https://hooks.slack.com/services/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 channel: general username: drone-bot template: "<{{build.link}}|Deployment #{{build.number}} started> on by: {{build.author}}" when: branch: [ master, staging ] ##################### build start ############################### # 2.1 build binary build: <<: *build_config commands: - echo "do something" - sleep 30 - echo "build success" when: branch: - develop - master # build_release: # <<: *build_config # when: # event: tag ##################### build & publish docker image ############## # 3. build docker images build_docker_image: image: plugins/docker commands: - make all # 4. publish images to test registry(tag: dev) # drone deploy octocat/hello-world 24 staging publish_develop: <<: *repo_config tag: - dev when: branch: develop event: push # 4. publish images to test registry # drone deploy octocat/hello-world 24 staging publish_latest: <<: *build_config tag: - latest - v0.4 when: branch: master event: push # 4. publish image to test registry # drone deploy octocat/hello-world 24 staging publish_release: <<: *build_config tag: - "${DRONE_TAG}" when: event: tag ################### deploy in test env ########################## # 5. deploy to rancher(test env) publish_to_test_env: <<: *deploy_config url: http://tyn.ar3qvx.com:8080 access_key: ${RANCHER_ACCESS_KEY_TEST} secret_key: ${RANCHER_SECRET_KEY_TEST} docker_image: tyn.ar3qvx.com/cdn/evlss # start new container before stopping old one, default to true start_first: false # auto confirm service upgrade confirm: true timeout: 240 # batch size for the service upgrade batch_size: 5 ##################### test in test env ########################## # test in rancher test_stage: image: dongcj/webshell commands: - sleep 20 ##################### deploy to production ###################### # test in rancher test_stage: image: dongcj/webshell commands: - sleep 20 ##################### notify start ############################## notify_test_stage: image: plugins/slack webhook: https://hooks.slack.com/services/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 channel: general username: drone-bot when: branch: [ master, staging ] status: [ success ] template: "<{{build.link}}|Deployment #{{build.number}} success> on by: {{build.author}}" notify_end_slack: image: plugins/slack webhook: https://hooks.slack.com/services/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 channel: general username: drone-bot when: branch: [ master, staging ] status: [ success, failure ] template: "<{{build.link}}|Deployment #{{build.number}} stop> on by: {{build.author}}" notify_end_email: image: drillster/drone-email host: smtp.mxhichina.com skip_verify: false username: admin@dongcj.com password: Dcj85509336 from: drone@svicloud.com recipients: [ dongchaojun@svi-tech.com.cn, admin@svicloud.com ] recipients_only: false when: status: [ changed, failure ]