【发布时间】:2019-10-01 04:35:04
【问题描述】:
我正在使用 Google Cloud Build 构建一个具有 100 多个依赖项的 java 项目。默认情况下,本地 maven 存储库缓存将为空,并且它每次构建时都会下载所有依赖项。
google 文档仅建议“使用 Google Cloud Storage 缓存目录”https://cloud.google.com/cloud-build/docs/speeding-up-builds,但同步 7000 个文件需要很长时间(这意味着构建速度较慢)
只有一个依赖是 5 个文件
repository/org/mockito
repository/org/mockito/mockito-core
repository/org/mockito/mockito-core/2.15.0
repository/org/mockito/mockito-core/2.15.0/mockito-core-2.15.0.jar
repository/org/mockito/mockito-core/2.15.0/mockito-core-2.15.0.jar.sha1
repository/org/mockito/mockito-core/2.15.0/mockito-core-2.15.0.pom
repository/org/mockito/mockito-core/2.15.0/mockito-core-2.15.0.pom.sha1
repository/org/mockito/mockito-core/2.15.0/_remote.repositories
一个示例 cloudbuild.yaml 文件
steps:
- name: gcr.io/cloud-builders/gsutil
args: ['rsync', '-r', 'gs://my-mavencache-bucket/repository', '.']
- name: 'gcr.io/$PROJECT_ID/mvn'
args: ['package']
...
我想将 gs://my-mavencache-bucket 挂载为一个卷 - 但我没有看到这样做的选项
【问题讨论】:
-
你有这个项目的例子吗?此外,您是否使用最新版本的 Maven 和所有插件?等
-
你能用关于慢的指标更新你的问题吗?你能提供一个构建需要多长时间的测量吗?如果你在 PC 上本地编译,没有任何东西下载到缓存中,需要多长时间?
-
我使用 maven 很多年了,问题不在于 maven 的版本或某些配置,它与 google cloud build 的工作方式有关 - 构建是一组步骤,其中每个步骤相当于 docker run 命令,/workspace 是这些步骤共享的公共目录。鉴于 Google Cloud Build 是推荐的构建标准,并且我正在使用 java 单体应用程序(相当主流的用例),我希望现在能找到一个示例,但还没有运气
-
似乎疯狂的谷歌 cloudbuild 缺少这个最基本的需求。在我们的例子中,构建需要 15 分钟而不是 2 分钟。 Jenkins、Bitbucket 等负责缓存 maven 存储库。
标签: java maven google-cloud-build