Ubuntu 如何使用shell runner设置GitLab CI?

Ubuntu 如何使用shell runner设置GitLab CI?,ubuntu,continuous-integration,gitlab,Ubuntu,Continuous Integration,Gitlab,我试图建立一个GitLab持续集成的最小工作示例。我成功地创建了一个工作的Spring启动应用程序,并将其推送到我的GitLab。我创建了一个.gitlab ci.yml文件,使用简单的: run: script: - ./gradlew bootRun 指挥部。在推动我的更改时,我得到了以下错误: Running with gitlab-ci-multi-runner 9.4.2 (6d06f2e) on Martin-asus-runner (7056052b) Using

我试图建立一个GitLab持续集成的最小工作示例。我成功地创建了一个工作的Spring启动应用程序,并将其推送到我的GitLab。我创建了一个
.gitlab ci.yml
文件,使用简单的:

run:
  script:
    - ./gradlew bootRun
指挥部。在推动我的更改时,我得到了以下错误:

Running with gitlab-ci-multi-runner 9.4.2 (6d06f2e)
  on Martin-asus-runner (7056052b)
Using Shell executor...
Running on martin-UX305UA...
Cloning repository...
Cloning into '/home/gitlab-runner/builds/7056052b/0/Martin/ci-test'...
Checking out b670a57a as master...
Skipping Git submodules setup
$ ./gradlew bootRun

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the location of your Java installation.

ERROR: Job failed: exit status 1
这很奇怪,因为我的电脑上安装了Java。仔细检查后,我发现GitLab CI可能在我的系统上创建了一个名为
GitLab runner
的新用户,并且所有CI脚本都由该用户执行。由于该用户尚未安装Java,因此未设置环境变量


解决这个问题的方法是什么?我能让
gitlab运行程序“继承”我的环境吗?

你能找到这个吗?“我也有类似的情况。”安德鲁克很遗憾,我们找到了解决办法。我刚刚在集成服务器上安装了docker,然后在
gitlab ci.yml
script:
部分中运行显式的
docker run openjdk:latest./gradlew bootRun
命令。我认为这是一个更好的解决方案,因为官方的
openjdk
docker容器已经很好地配置了环境。谢谢,我最终做了类似的事情,我不得不运行一个新的服务器,我可以设置它来满足我项目的需要。祝你发展顺利!