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: line 60: mvn: command not found
ERROR: Job failed: exit status 1
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
I add also the line :
environment = ["MAVEN_HOME=/usr/local/apache-maven"]
on the config.toml file.
the problem still persist, my executor is : shell.
Any advice!
I managed to fix the problem using this workaround:
script:
- $MAVEN_HOME/bin/mvn clean
Just add the maven docker image, add below line as first line:
image: maven:latest or image: maven:3-jdk-10 or image: maven:3-jdk-9
refer: https://docs.gitlab.com/ee/ci/examples/artifactory_and_gitlab/
For anyone experiencing similar issues, it might be a good idea to restart the gitlab runner ".\gitlab-runner.exe restart". Especially after fiddling with environmental variables.
There is an easier way:
Making changes in ~/.bash_profile
not ~/.bashrc
.
According to this document:
.bashrc
it is more common to use a non-login shell
This document saying:
For certain executors, the runner passes the
--login
flag as shown above, which also loads the shell profile.
So it should not be ~/.bashrc
, you can also try ~/.profile
which It can hold the same configurations, which are then also accessible by other shells
In my scenario I do following things:
gitlab-runner
's user password.passwd gitlab-runner
gitlab-runner
.su - gitlab-runner
.bash_profile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With