123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- ##################### 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 <http://tyn.ar3qvx.com:3000/{{repo.owner}}/{{repo.name}}/tree/{{build.branch}}|{{repo.name}}:{{build.branch}}> 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 <http://http://tyn.ar3qvx.com:3000/{{repo.owner}}/{{repo.name}}/tree/{{build.branch}}|{{repo.name}}:{{build.branch}}> 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 <http://http://tyn.ar3qvx.com:3000/{{repo.owner}}/{{repo.name}}/tree/{{build.branch}}|{{repo.name}}:{{build.branch}}> 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 ]
|