kind: pipeline type: docker name: CI Process steps: ### 打包应用代码和资源 - name: Maven Package image: maven:3.5.3-jdk-8 environment: # 应用专案名称(需手动修改) backendName: demo-athenaopt_backend # 平台API版本号(需手动修改) apiVersion: 5.2.0.1029 commands: # 在开发根目录下执行 maven package 指令以构建运行包 - mvn -f $backendName/pom.xml package -Dapi.version=$apiVersion -Dnexus.ip=https://repo.digiwincloud.com.cn/maven - mkdir -p $backendName/running # 将构建出来的文件复制到用于放置运行包的 running 目录下 # 注意:此处将运行包放到 running 目录只是暂存,还需要在 Dockerfile-drone 中再把 running 下的文件复制到 Docker 容器的工作目录下 - cp -r $backendName/develop/target/$backendName/* $backendName/running volumes: - name: cache # The Volume's name path: /root/.m2 # The path in the container when: status: [ success ] branch: # - develop # - master - release/s4 event: - push ### 应用版本控制:检查版本文件,若不存在则自动创建,并自动递增版本号 - name: Version Control image: registry.digiwincloud.com.cn/base/base_vc environment: # 应用专案名称(需手动修改) backendName: demo-athenaopt_backend commands: - sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories - apk add tree --no-cache - tree ./$backendName - make branch=release/s4 vc # - make branch=master vc when: status: [ success ] branch: # - develop # - master - release/s4 event: - push ### 打包镜像并推送到镜像仓库 - name: Package Docker Image & Push image: plugins/docker:20.10.9 environment: # 应用专案名称(需手动修改) backendName: demo-athenaopt_backend ## Docker 插件的设置 settings: insecure: true username: from_secret: dockerUsername password: from_secret: dockerPassword # 注意:此处不支持用取值符号获取参数,需要手动修改。${appId} 表示应用ID,${projectName} 表示仓库项目名称,${platformVersion} 表示平台版本号 # 例如:registry.digiwincloud.com.cn/sampleapp1/sampleapp1backend-5.0.1 注意APPID和backend中间没有下划线 # repo: registry.digiwincloud.com.cn/${projectName}/${appId}backend-${platformVersion} repo: registry.digiwincloud.com.cn/athenaopt/demo-athenaoptbackend-5.2.0 registry: registry.digiwincloud.com.cn experimental: true # 打包镜像时会用到的 Dockerfile 文件(此处使用自定义 Dockerfile 文件名,避免跟其他 Dockerfile 冲突) dockerfile: Dockerfile # 将环境变量传递给 Docker 镜像 build_args_from_env: backendName when: status: [ success ] branch: # - develop # - master - release/s4 ### 应用版本控制:提交版本文件的修改记录,并为代码分支创建版本号标签 - name: Upload Version image: registry.digiwincloud.com.cn/base/base_vc commands: # - make branch=develop to_git # - make branch=master to_git - make branch=release/s4 to_git when: status: [ success ] branch: # - develop # - master - release/s4 event: - push trigger: branch: # - develop # - master - release/s4 event: - push volumes: - name: cache host: path: /data/drone/var/lib/cache/maven