作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 GitLab CI 上使用并行 Gradle 作业:
我收到以下随机 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-runner
的 docker
执行器,没有任何 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/
我是一名优秀的程序员,十分优秀!