gpt4 book ai didi

docker - Gradle 在 GitLab CI 上构建 : Could not create service of type ScriptPluginFactory

转载 作者:行者123 更新时间:2023-12-02 18:52:51 27 4
gpt4 key购买 nike

GitLab CI 上使用并行 Gradle 作业:

Parallel Gradle jobs

我收到以下随机 Gradle 异常:

FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type ResourceSnapshotterCacheService using GradleUserHomeScopeServices.createResourceSnapshotterCacheService().

我使用 gitlab-runnerdocker 执行器,没有任何 GitLab CI 缓存。我使用 Docker 卷,而不是 Gradle 缓存指向该卷:

before_script:
- export GRADLE_USER_HOME=/pipelines/.gradle

/pipelines 目录的访问权限没有问题(因此这不是 this question 的口是心非)。

解决此问题的简单但烦人的解决方法就是手动重新触发失败的作业 - 然后它就可以顺利通过。另一种解决方法可以通过 retry 自动重新触发作业。指令。

所以,我的问题是:是什么导致了作业失败以及如何解决(无需重新触发作业)

最佳答案

根本原因:

经过一些调试(切换 --stacktrace--info),很明显,根本原因是多个 Docker 容器在主机上共享一个 Gradle 缓存。

Caused by: org.gradle.cache.LockTimeoutException: Timeout waiting to lock file hash cache (/pipelines/.gradle/caches/4.10.2/fileHashes). It is currently in use by another Gradle instance.
Owner PID: 158
Our PID: 160
Owner Operation:
Our operation:
Lock file: /pipelines/.gradle/caches/4.10.2/fileHashes/fileHashes.lock

解决方案:

仍有 Unresolved Gradle 错误/功能:Let multiple containers share downloaded dependencies 。因此,我(重新)为每个涉及的 GitLab CI 作业实现了适当的 Gradle 缓存(因此,没有共享缓存😢):

before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle

rpmClient:
stage: buildRpm
script:
- gradle clientRpm
cache:
paths:
- .gradle/caches

关于docker - Gradle 在 GitLab CI 上构建 : Could not create service of type ScriptPluginFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53186389/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com