I am running my Maven/Spring project in Jenkins (just testing it out, first time) using the shell script option with:
mvn spring-boot:run
I get the build error:
/Users/Shared/Jenkins/tmp/jenkins8087926087546049217.sh: line 2: mvn: command not found
How can I fix this? Its a Spring-boot app. It works fine when I run mvn spring-boot:run
via command line.
"Manage Jenkins"->"Global Tool Configuration"
if still not work, add the following to "Execute shell"
export MAVEN_HOME=/opt/maven
export PATH=$PATH:$MAVEN_HOME/bin
mvn --version
mvn clean package
export MAVEN_HOME=/opt/maven
export PATH=$PATH:$MAVEN_HOME/bin
mvn --version
mvn clean package
and then mvn install
I also met the problem and solved it. I think you may be using a "FreeStyle Project" instead of a "Maven Project" when you creating a new project via "New Item" button.
In FreeStyle Project, Jenkins may not read environment variables in Linux server and the Maven installations in "Global Tool Configuration", so I configured environment variables repeatedly in "Configure System". Then it worked.
Try this, Navigate to Manage Jenkins and click on Global Tool Configuration, In Maven section click on the 'Add Maven' button and provide the maven installation path in MAVEN_HOME and save configurations.
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