kind: pipeline type: docker name: drone-dev-db-bastion-server # 触发器 trigger: # 触发分支 branch: - master # 触发事件 event: - push # 事件状态 status: - success # 共享目录 volumes: - name: maven-cache host: path: /data/drone/m2/cache - name: docker-sock host: path: /var/run/docker.sock - name: env-files host: path: /niushuai233/env # ci 步骤 steps: # 打包jar - name: maven-package image: maven:3.6.3-jdk-8 volumes: - name: maven-cache path: /root/.m2 commands: - echo 'maven package start' # 打包 - mvn clean package -Dmaven.test.skip=true # 构建镜像 - name: build-image image: docker:dind volumes: - name: docker-sock path: /var/run/docker.sock commands: - echo 'build image start' # 构建新镜像 - docker build -t niushuai233/db-bastion-server:latest . # 清理无用镜像 - docker image prune -f --filter "dangling=true" # 启动服务 - name: deploy image: docker:dind volumes: - name: docker-sock path: /var/run/docker.sock - name: env-files path: /niushuai233/env commands: - echo 'deploy start' - pwd - ls -alh - sh deploy.sh