You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.6 KiB

2 years ago
  1. ---
  2. kind: pipeline
  3. type: docker
  4. name: default
  5. volumes:
  6. - name: gopath
  7. host:
  8. path: /usr/local/path/gopath
  9. steps:
  10. - name: code-analysis
  11. image: aosapps/drone-sonar-plugin
  12. settings:
  13. sonar_host: http://192.168.1.252:19000
  14. sonar_token: c38d5625bfd0c9027cbb54ddb80968d6b7601733
  15. when:
  16. target: ["develop","test","pre"]
  17. - name: golang-build
  18. image: golang
  19. volumes:
  20. - name: gopath
  21. path: /go
  22. commands:
  23. - export GOPROXY=gitea.241210.com,mirrors.aliyun.com/goproxy/,gocenter.io,proxy.golang.org,goproxy.cn,gonexus.dev
  24. - export GOPRIVATE=gitea.241210.com
  25. - cd web/
  26. # - export GOPROXY=https://gocenter.io
  27. # - export GOPROXY=https://proxy.golang.org
  28. # - export GOPROXY=https://goproxy.cn
  29. # - export GOPROXY=https://mirrors.aliyun.com/goproxy/
  30. # - export GOPROXY=https://gonexus.dev
  31. - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gy-uuos-web
  32. when:
  33. target: ["develop","test","pre"]
  34. - name: docker-push
  35. image: plugins/docker
  36. settings:
  37. username: docker-push
  38. password: WeWlh6hGYCtxO4r
  39. repo: repository.241210.com/repository/gyys/drone/gy-uuos
  40. dockerfile: web/Dockerfile
  41. registry: https://repository.241210.com
  42. tags: ${DRONE_BUILD_NUMBER}
  43. when:
  44. target: ["develop","test","pre"]
  45. - name: deployment-replace
  46. image: repository.241210.com/repository/base/kubectl:4
  47. commands:
  48. - cd web/
  49. - sed -i 's!IMAGE_PATH:IMAGE_TAG!'repository.241210.com/repository/gyys/drone/gy-uuos:${DRONE_BUILD_NUMBER}'!g' deployment.yaml
  50. when:
  51. target: ["develop","test","pre"]
  52. - name: deploy
  53. image: repository.241210.com/repository/base/kubectl:4
  54. commands:
  55. - cd web/
  56. - kubectl --kubeconfig /kube/${CI_BUILD_TARGET:-develop} apply -f deployment.yaml
  57. when:
  58. target: ["develop","test","pre"]
  59. ## 使用参数推送稳定镜像
  60. - name: deployment-replace-prod
  61. image: repository.241210.com/repository/base/kubectl:4
  62. commands:
  63. - cd web/
  64. - sed -i 's!IMAGE_PATH:IMAGE_TAG!'${IMAGE}'!g' deployment.yaml
  65. when:
  66. target: ["exp","prod"]
  67. - name: deploy-prod
  68. image: repository.241210.com/repository/base/kubectl:4
  69. commands:
  70. - cd web/
  71. - kubectl --kubeconfig /kube/${CI_BUILD_TARGET} apply -f deployment.yaml
  72. when:
  73. target: ["exp","prod"]
  74. # - name: ding
  75. # image: lddsb/drone-dingtalk-message
  76. # settings:
  77. # token: f09f64151159f9243e771503ae4a5ef5af3e079f6828b464c17ea2bb291523c2
  78. # type: markdown
  79. # sha_link: true
  80. # when:
  81. # status: [success, failure]