kind: pipeline type: kubernetes name: build-and-deploy-dev trigger: event: - push branch: - dev steps: - name: restore-cache restore_cache: keys: - maven-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "pom.xml" }} - maven-{{ .Environment.DRONE_REPO_NAME }}- - name: build image: ccr.ccs.tencentyun.com/violin/maven:3.9-eclipse-temurin-22 commands: - mvn clean package -DskipTests cache_from: - maven-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "pom.xml" }} - name: build-image image: ccr.ccs.tencentyun.com/violin/docker:linux-amd64 settings: repo: ccr.ccs.tencentyun.com/violin/todo-backend tags: - ${DRONE_COMMIT_SHA} - latest username: from_secret: registry_username password: from_secret: registry_password - name: deploy-to-k8s image: bitnami/kubectl:latest commands: - kubectl set image deployment/todo-backend todo-backend=ccr.ccs.tencentyun.com/violin/todo-backend:${DRONE_COMMIT_SHA} -n todo-test - kubectl rollout status deployment/todo-backend -n todo-test environment: KUBECONFIG: from_secret: kubeconfig when: status: - success - name: rebuild-cache rebuild_cache: keys: - maven-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "pom.xml" }} - maven-{{ .Environment.DRONE_REPO_NAME }}- --- kind: pipeline type: kubernetes name: build-and-deploy-prod trigger: event: - push branch: - master steps: - name: restore-cache restore_cache: keys: - maven-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "pom.xml" }} - maven-{{ .Environment.DRONE_REPO_NAME }}- - name: build image: ccr.ccs.tencentyun.com/violin/maven:3.9-eclipse-temurin-22 commands: - mvn clean package -DskipTests cache_from: - maven-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "pom.xml" }} - name: build-image image: ccr.ccs.tencentyun.com/violin/docker:linux-amd64 settings: repo: ccr.ccs.tencentyun.com/violin/todo-backend tags: - ${DRONE_COMMIT_SHA} - v1.0.0 username: from_secret: registry_username password: from_secret: registry_password - name: deploy-to-k8s image: bitnami/kubectl:latest commands: - kubectl set image deployment/todo-backend todo-backend=ccr.ccs.tencentyun.com/violin/todo-backend:${DRONE_COMMIT_SHA} -n todo-prod - kubectl rollout status deployment/todo-backend -n todo-prod environment: KUBECONFIG: from_secret: kubeconfig when: status: - success - name: rebuild-cache rebuild_cache: keys: - maven-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "pom.xml" }} - maven-{{ .Environment.DRONE_REPO_NAME }}-