Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
windows
-
-
pipeline-maven-3.11.0
Description
in a clean jenkins (no maven plugin installed)
In an agent without maven on the path add MAVEN_HOME to the environment variables for the node.
run the follwoing pipeline
node { bat "set" withMaven { git changelog: false, poll: false, url: 'https://github.com/jtnord/maven-test-project.git' bat "mvn package" } }
This should work as MAVEN_HOME is in the environment as confimerd by the set command.
However it fails with the following message
[withMaven] use JDK installation provided by the build agent
$ where mvn.cmd
$ where mvn.bat
[withMaven] use Maven installation provided by the build agent with executable null
[Pipeline] // withMaven
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Could not find maven executable, please set up a Maven Installation or configure MAVEN_HOME or M2_HOME environment variable
But MAVEN_HOME is defined - so this is just plain wrong...
Attachments
Issue Links
- is duplicated by
-
JENKINS-61612 withMaven does not detect maven
-
- Closed
-
- is related to
-
JENKINS-61612 withMaven does not detect maven
-
- Closed
-
- links to
Many thanks. I think the problem was that we didn't need a tools section before and now we do and it caught us off guard.
Once I'd got the Maven installations set up in Jenkins so that it was downloading the correct version of Maven (as part of the pipeline) I found that JAVA_HOME was not being set. Maybe this would have been set if I added a JDK to the Jenkins configuration but we use Java11 and it is not possible to add a platform folder as the java home. (You have to install from zip or from Oracle+license etc). For that I had to add a global environment variable for JAVA_HOME which seemed a bit disconnected but this is probably going slightly off-topic as it's not strictly part of withMaven; however withMaven gets a bit confused if JAVA_HOME is not set properly.
Thanks for the tip about building it myself, I will look into that.