If I create a Maven job in Jenkins (New Item => Maven project, using the maven plugin) with all defaults and run it, I get this error:
For me, the solution was to go to Manage Jenkins -> Global Tool Configuration, and set up maven there. You can access this via /configureTools (ex: http://your-ip:8080/jenkins/configureTools )
Example: Maven installations
Additional configurations for other common tools at /configureTools :
Git installations
JDK installations
Assuming you have Java and Maven installed on your slave:
It should now work (even if you have configured a Maven installation on the master).
If you do NOT add Maven to the Master configuration and you just install it on every slave with their own possibly different environment variables (example with version 3.2.5)
M2_HOME=C:\apache-maven-3.2.5
M2=C:\apache-maven-3.2.5\bin
Path+=;C:\apache-maven-3.2.5\bin
then every Jenkins slave will just use Maven with local settings.
To make it simple, just use my public docker image
docker push chiraggupta95/jenkinswithmvn:v1
In case you want to customize your own image, just check out my git repo for complete instructions.
https://github.com/chiraggupta95apr/jenkins
Happy Coding :)