无人机管道:无法解析 Maven 存储库的无人机缓存安装路径

问题描述 投票:0回答:1

我是 Drone pipeline 的新手,有兴趣在我当前的 CICD 项目中使用它。 我的项目技术堆栈如下:

  1. Java
  2. 春季启动
  3. Maven

我创建了一个示例无人机管道,但无法缓存下载并存储在 .m2 文件夹中的 Maven 依赖项。 总是说挂载路径不可用或未找到。请找到相同的屏幕截图:

无人机安装路径问题

不确定此处提供的路径。有人可以帮助我理解我们需要提供的安装路径来缓存 .m2 路径中的所有依赖项。 添加以下管道信息:

kind: pipeline
type: docker
name: config-server

steps:

name: restore-cache
image: meltwater/drone-cache
pull: if-not-exists
settings:
backend: "filesystem"
restore: true
cache_key: "volume"
archive_format: "gzip"
mount:
- ./target
- /root/.m2/repository
volumes:
name: cache
path: /tmp/cache

name: build
image: maven:3.8.3-openjdk-17
pull: if-not-exists
environment:
M2_HOME: /usr/share/maven
MAVEN_CONFIG: /root/.m2
commands: 
mvn clean install -DskipTests=true -B -V
volumes:
name: cache
path: /tmp/cache

name: rebuild-cache
image: meltwater/drone-cache
pull: if-not-exists
settings:
backend: "filesystem"
rebuild: true
cache_key: "volume"
archive_format: "gzip"
mount:
- ./target
- /root/.m2/repository
volumes:
name: cache
path: /tmp/cache

trigger:
branch:
main
event:
push

volumes:
name: cache
host:
path: /var/lib/cache

提前致谢..

maven-3 pipeline drone.io volumes mount-point
1个回答
1
投票

解决了问题。请找到下面的解决方案和工作无人机管道。

kind: pipeline
type: docker
name: data-importer

steps:

- name: restore-cache
  image: meltwater/drone-cache
  pull: if-not-exists
  settings:
    backend: "filesystem"
    restore: true
    ttl: 1
    cache_key: "volume"
    archive_format: "gzip"
    mount:
      - ./.m2/repository
  volumes:
  - name: cache
    path: /tmp/cache
    
- name: maven-build
  image: maven:3.8.6-amazoncorretto-11
  pull: if-not-exists
  commands:
    - mvn clean install -DskipTests=true -Dmaven.repo.local=.m2/repository -B -V
  volumes:
  - name: cache
    path: /tmp/cache
   
- name: rebuild-cache
  image: meltwater/drone-cache
  pull: if-not-exists
  settings:
    backend: "filesystem"
    rebuild: true
    cache_key: "volume"
    archive_format: "gzip"
    ttl: 1
    mount:
      - ./.m2/repository
  volumes:
  - name: cache
    path: /tmp/cache
    
trigger:
  branch:
  - main
  - feature/*
  event:
  - push
  
volumes:
  - name: cache
    host:
      path: /var/lib/cache
© www.soinside.com 2019 - 2024. All rights reserved.