--- kind: pipeline type: docker name: default volumes: - name: gopath host: path: /usr/local/path/gopath steps: - name: golang-build image: golang volumes: - name: gopath path: /go commands: - export GOPROXY=https://goproxy.cn - go mod init test-drone - go mod tidy - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o test-drone when: target: [ "" ] - name: docker-push image: plugins/docker settings: username: tjqmhu password: tjqm4912 repo: registry.cn-hangzhou.aliyuncs.com/huvipg/drone/test-drone dockerfile: Dockerfile registry: https://registry.cn-hangzhou.aliyuncs.com tags: ${DRONE_BUILD_NUMBER} when: target: [ "" ] # - name: deployment-replace # image: repository.241210.com/repository/base/kubectl:4 # commands: # - sed -i 's!IMAGE_PATH:IMAGE_TAG!'${IMAGE}'!g' deployment.yaml # when: # target: [ "develop","test" ] # # - name: deploy # image: repository.241210.com/repository/base/kubectl:4 # commands: # - kubectl --kubeconfig /kube/${CI_BUILD_TARGET:-develop} apply -f deployment.yaml # when: # target: [ "develop","test" ] # ## 使用参数推送稳定镜像 # - name: deployment-replace-prod # image: repository.241210.com/repository/base/kubectl:4 # commands: # - sed -i 's!IMAGE_PATH:IMAGE_TAG!'${IMAGE}'!g' deployment.yaml # when: # target: [ "pre","prod" ] # # - name: deploy-prod # image: repository.241210.com/repository/base/kubectl:4 # commands: # - kubectl --kubeconfig /kube/${CI_BUILD_TARGET} apply -f deployment.yaml # when: # target: [ "pre","prod" ]