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.

104 lines
3.6 KiB

1 year ago
  1. kind: pipeline
  2. type: docker
  3. name: CI Process
  4. steps:
  5. ### 打包应用代码和资源
  6. - name: Maven Package
  7. image: maven:3.5.3-jdk-8
  8. environment:
  9. # 应用专案名称(需手动修改)
  10. backendName: app-code_backend
  11. # 平台API版本号(需手动修改)
  12. apiVersion: 5.2.0.1005
  13. commands:
  14. # 在开发根目录下执行 maven package 指令以构建运行包
  15. - mvn -f $backendName/pom.xml package -Dapi.version=$apiVersion -Dnexus.ip=https://repo.digiwincloud.com.cn/maven
  16. - mkdir -p $backendName/running
  17. # 将构建出来的文件复制到用于放置运行包的 running 目录下
  18. # 注意:此处将运行包放到 running 目录只是暂存,还需要在 Dockerfile-drone 中再把 running 下的文件复制到 Docker 容器的工作目录下
  19. - cp -r $backendName/develop/target/$backendName/* $backendName/running
  20. volumes:
  21. - name: cache # The Volume's name
  22. path: /root/.m2 # The path in the container
  23. when:
  24. status: [ success ]
  25. branch:
  26. # - develop
  27. # - master
  28. - release/S1
  29. event:
  30. - push
  31. ### 应用版本控制:检查版本文件,若不存在则自动创建,并自动递增版本号
  32. - name: Version Control
  33. image: registry.digiwincloud.com.cn/base/base_vc
  34. environment:
  35. # 应用专案名称(需手动修改)
  36. backendName: app-code_backend
  37. commands:
  38. - sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
  39. - apk add tree --no-cache
  40. - tree ./$backendName
  41. - make branch=release/S1 vc
  42. # - make branch=master vc
  43. when:
  44. status: [ success ]
  45. branch:
  46. # - develop
  47. # - master
  48. - release/S1
  49. event:
  50. - push
  51. ### 打包镜像并推送到镜像仓库
  52. - name: Package Docker Image & Push
  53. image: plugins/docker:20.10.9
  54. environment:
  55. # 应用专案名称(需手动修改)
  56. backendName: app-code_backend
  57. ## Docker 插件的设置
  58. settings:
  59. insecure: true
  60. username:
  61. from_secret: dockerUsername
  62. password:
  63. from_secret: dockerPassword
  64. # 注意:此处不支持用取值符号获取参数,需要手动修改。${appId} 表示应用ID,${projectName} 表示仓库项目名称,${platformVersion} 表示平台版本号
  65. # 例如:registry.digiwincloud.com.cn/sampleapp1/sampleapp1backend-5.0.1 注意APPID和backend中间没有下划线
  66. # repo: registry.digiwincloud.com.cn/${projectName}/${appId}backend-${platformVersion}
  67. repo: registry.digiwincloud.com.cn/athenaopt/app-codebackend-5.2.0
  68. registry: registry.digiwincloud.com.cn
  69. experimental: true
  70. # 打包镜像时会用到的 Dockerfile 文件(此处使用自定义 Dockerfile 文件名,避免跟其他 Dockerfile 冲突)
  71. dockerfile: Dockerfile
  72. # 将环境变量传递给 Docker 镜像
  73. build_args_from_env: backendName
  74. when:
  75. status: [ success ]
  76. branch:
  77. # - develop
  78. # - master
  79. - release/S1
  80. ### 应用版本控制:提交版本文件的修改记录,并为代码分支创建版本号标签
  81. - name: Upload Version
  82. image: registry.digiwincloud.com.cn/base/base_vc
  83. commands:
  84. # - make branch=develop to_git
  85. # - make branch=master to_git
  86. - make branch=release/S1 to_git
  87. when:
  88. status: [ success ]
  89. branch:
  90. # - develop
  91. # - master
  92. - release/S1
  93. event:
  94. - push
  95. trigger:
  96. branch:
  97. # - develop
  98. # - master
  99. - release/S1
  100. event:
  101. - push
  102. volumes:
  103. - name: cache
  104. host:
  105. path: /data/drone/var/lib/cache/maven