错误的Java_home设置为使用Gitlab CI/CD的Docker内部无效目录
这是我第一次使用gitlab ci/cd和docker时,
我有一个小管道,有几个作业:
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew
stages:
- build
create common folder to store build:
stage: build
needs: []
tags:
- shell
script:
- mkdir popa
artifacts:
paths:
- ./popa
get debug apk build:
stage: build
needs: [create common folder to store build]
tags:
- shell
script:
- ./gradlew app:assembleDebug
- mv app/build/outputs/apk/debug/*.apk ./popa
artifacts:
paths:
- ./popa
get release apk build:
stage: build
needs: [create common folder to store build]
tags:
- shell
script:
- ./gradlew app:assembleRelease
- mv app/build/outputs/apk/release/*.apk ./popa
artifacts:
paths:
- ./popa
get release aab build:
stage: build
needs: [create common folder to store build]
tags:
- shell
script:
- ./gradlew app:bundleRelease
- mv app/build/outputs/bundle/release/*.aab ./popa
artifacts:
paths:
- ./popa
get one folder build:
stage: build
tags:
- shell
needs: [get debug apk build, get release apk build, get release aab build]
script:
- echo "DONE"
artifacts:
paths:
- ./popa
当我使用shell遗嘱执行人(带有macOS设置)时,一切都很好。 当我使用Docker时,我会收到以下错误:
ERROR: JAVA_HOME is set to an invalid directory: /Users/qfunz/.sdkman/candidates/java/current
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
我在MacOS中检查一下
echo $JAVA_HOME
并得到此错误,
/Users/qfunz/.sdkman/candidates/java/current
因此我在Gitlab CI/CD设置中添加了此错误 - 变量(java_home =/users/qfunz/.sdkman/candidates/candidates/java/current)
但是, 我在Docker跑步,
java
我什么都没得到。 我知道Docker有个人文件系统,但我不明白如何解决此问题
this is the first time when I use Gitlab CI/CD and Docker
I have a small pipeline with several jobs:
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew
stages:
- build
create common folder to store build:
stage: build
needs: []
tags:
- shell
script:
- mkdir popa
artifacts:
paths:
- ./popa
get debug apk build:
stage: build
needs: [create common folder to store build]
tags:
- shell
script:
- ./gradlew app:assembleDebug
- mv app/build/outputs/apk/debug/*.apk ./popa
artifacts:
paths:
- ./popa
get release apk build:
stage: build
needs: [create common folder to store build]
tags:
- shell
script:
- ./gradlew app:assembleRelease
- mv app/build/outputs/apk/release/*.apk ./popa
artifacts:
paths:
- ./popa
get release aab build:
stage: build
needs: [create common folder to store build]
tags:
- shell
script:
- ./gradlew app:bundleRelease
- mv app/build/outputs/bundle/release/*.aab ./popa
artifacts:
paths:
- ./popa
get one folder build:
stage: build
tags:
- shell
needs: [get debug apk build, get release apk build, get release aab build]
script:
- echo "DONE"
artifacts:
paths:
- ./popa
and when I use the Shell executor (with macOS setup) everything is fine. But when I use Docker I get the following error:
ERROR: JAVA_HOME is set to an invalid directory: /Users/qfunz/.sdkman/candidates/java/current
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
I check this in my macOS
echo $JAVA_HOME
and get this
/Users/qfunz/.sdkman/candidates/java/current
so I added this in Gitlab CI/CD Settings - Variables (JAVA_HOME = /Users/qfunz/.sdkman/candidates/java/current)
When I run in Docker
java
I get nothing.
I understand that Docker has the personal file system, but I can't understand how to fix this problem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用定制的Docker图像之一( Jangrewe/gitlab-ci-android ),该图像用于Android builds
Try using one of the customized docker images(jangrewe/gitlab-ci-android) which are meant to use for android builds