我正在运行 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/