Gitlab CI/CD 运行器:找不到 mvn 命令 [英] Gitlab CI/CD runner : mvn command not found
问题描述
Maven 已安装在我的 gitlab-runner 服务器上.当直接在我的 repo 上执行 mvn clean
时,它可以工作,当使用 Gitlab UI 运行我的管道时出现此错误:
Maven is well installed on my gitlab-runner server. When executing mvn clean
directly on my repo it works, when running my pipeline using Gitlab UI got this error :
bash:第 60 行:mvn:找不到命令
bash: line 60: mvn: command not found
错误:作业失败:退出状态 1
ERROR: Job failed: exit status 1
我注意到我试图通过在 .gitlab-ci.yml 文件中添加 before_script
部分来解决问题:
I notice that I tried to fix the problem by adding the before_script
section in the .gitlab-ci.yml file :
before_script:
- export MAVEN_HOME=/usr/local/apache-maven
我还添加了一行:
environment = ["MAVEN_HOME=/usr/local/apache-maven"]
在 config.toml 文件上.
问题依旧,我的执行者是:shell.
the problem still persist, my executor is : shell.
任何建议!
推荐答案
我设法使用此解决方法解决了问题:
I managed to fix the problem using this workaround:
script:
- $MAVEN_HOME/bin/mvn clean
这篇关于Gitlab CI/CD 运行器:找不到 mvn 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!