mvn not found on $JENKINS_HOME/workspace/<projectname>@tmp

4,037 views
Skip to first unread message

banthita limwilai

unread,
Mar 24, 2021, 7:23:13 AM3/24/21
to jenkins...@googlegroups.com
I've locally installed maven on both Master and Slave
and correctly set path for both JAVA_HOME and M2

jenkins@jenkins-slave-02:~$ echo $M2_HOME
/opt/maven
jenkins@jenkins-slave-02:~$ echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-amd64


Once reach the stage involved mvn command, the error occurs
/jenkins/workspace/simple_any_tests_master@tmp/durable-c32a56b1/script.sh: 1: mvn: not found

I notice that this @tmp dir was empty which means no pom.xml and when looking closely by reproduce the mvn compile in @tmp dir

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.117 s
[INFO] Finished at: 2021-03-24T12:09:50+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException


I'm not sure what is the root cause of this error whereas incorrect maven path or slave setting (permission, etc.)

Any helps would be appreciated
Cheers

Mallarapu Ananth

unread,
Mar 24, 2021, 8:00:21 AM3/24/21
to Jenkins Users
Hi , 

Have tried to print the M2_HOME and JAVA_HOME in the pipeline you are trying to build . if they are empty it might be getting overwritten . try to put then as environment variables in jenkins config . 

John Patrick

unread,
Mar 24, 2021, 1:51:15 PM3/24/21
to jenkins...@googlegroups.com
Personally I would switch to using maven wrapper as it have saved me
from a lot of issues like this.

But to your errors;

From your first error, check if mvn is on the path, so I would expect
to see "/opt/maven/bin" within the PATH assuming "/opt/maven" is where
maven is installed. Doesn't matter what M2_HOME or JAVA_HOME are until
mvn is on the path.

The second error implies you've not told maven what to do, as that
looks like a maven output. So it has managed to do "mvn" without any
arguments, so you need to do "mvn clean install" or "mvn verify".

For the existing Wrapper see https://github.com/takari/maven-wrapper
From the next Maven release see this wrapper
https://maven.apache.org/plugins/maven-wrapper-plugin/index.html

John
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/efd1fb38-db5e-45dc-8ea6-437f9668c417n%40googlegroups.com.

banthita limwilai

unread,
Mar 25, 2021, 5:04:59 AM3/25/21
to jenkins...@googlegroups.com
Hi :)

From the previous email, I asked for help about my Jenkins Slave unable to run mvn

I'd like to share what I've founded and the solution for the problem. 
I basically set the PATH for M2_HOME and MAVEN_HOME at /etc/profile which is somehow not work with the system's permission

So, I changed to set M2_HOME and MAVEN_HOME at /etc/environment instead and then the problem was gone :D
It's not Jenkins issue not even relate LOL but it's Linux 101

Anyway, amy thanks for Mallarapu Ananth and John for the suggestion. It was helpful

Cheers

ในวันที่ พฤ. 25 มี.ค. 2021 เวลา 00:51 John Patrick <nhoj.p...@gmail.com> เขียนว่า:
Reply all
Reply to author
Forward
0 new messages