Gradle 仅在 CI 工作期间提示缺少 jar

标签 gradle continuous-integration gitlab git-submodules

我正在运行 gradle assemble在 gitlab 工作中:

image: gradle:alpine

variables:
  GRADLE_OPTS: "-Dorg.gradle.daemon=false"
  GIT_SUBMODULE_STRATEGY: normal

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

build:
  stage: build
  script:
    - gradle assemble
  artifacts:
    paths:
      - build/libs/*.jar

after_script:
    - ls -R
gradle assemble显示没有问题并且在我的物理机器上构建良好,但在运行机上我得到以下信息:
Execution failed for task ':jar'.
> Failed to create MD5 hash for file '/builds/project/subproject/build/libs/subproject.jar' as it does not exist.

其中子项目是一个 git 子模块。

我希望该项目能够像在本地一样构建,有什么想法吗?

编辑

添加我的 .gitmodules 文件:
[submodule "submodule"]
    path = submodule
    url = https://github.com/thechubbypanda/submodule.git

在 gradle 脚本运行之前,子模块的所有文件都存在

最佳答案

您忘记运行命令来拉取所有子模块:

在您的 before_script 中执行此操作还有:

git submodule sync --recursive
git submodule update --init --recursive

还要确保您已经在 .gitmodules 中声明了子模块。文件。

https://docs.gitlab.com/ee/ci/yaml/README.html#git-submodule-strategy

关于Gradle 仅在 CI 工作期间提示缺少 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61685863/

相关文章:

java - 如何在 gradle 中设置库构建顺序?

android - 从build.gradle读取元数据

java - 如何一起使用 LibGDX、Gradle、Git 和 Eclipse?

continuous-integration - Codemagic 自动构建未被触发

node.js - 如何在具有持续集成的gitlab中存储作业和阶段之间的 Node 模块

docker - 在构建 Docker 镜像时使用来自私有(private) gitlab 存储库的 pip install

spring - 使用 gradle 依赖插件的快照版本(...为了测试 gradle-3.0Mx)

MSBuild 无法确定正确的解决方案依赖项

macos - 无法创建目录/var/teamsserver

python - Gitlab CI Runner 无法在 Python 中导入 Google.Cloud