2

I have configured Jenkins to install maven automatically on slaves when building the first time. This works when I run jobs that were created off of "Maven Project" templates. I just have to specify the goals and everything works.

enter image description here

It is with free-style software projects that I am having trouble with. How do I tell Jenkins to pass the path of installed maven to these jobs? For now, I am adding the maven path in the build section of the jobs.

I added the maven path to ~/.bashrc, ~/.bash_profile on the slave, but that didn't help either.

Indrajeet
  • 521
  • 3
  • 9
  • 23

2 Answers2

5

It is in the Build section only that you define the Maven version. It provides you the flexibility to select different version for different projects. However, if you have only one version of Maven installed, then you simply have to make sure that it is present in the PATH variable. To set the same on any of the Jenkins' slave, just go to the slave's configuration page and add it in the path. You can refer the screenshot below for reference:

enter image description here

Technext
  • 7,887
  • 9
  • 48
  • 76
  • 2
    I also realized that I can specify the name and home of Maven tool under "Tool Locations". But that doesn't help the job. The job fails to locate the mvn command. The only solution is to edit the PATH variable under "Environment Variables" as you suggest. I then, wonder what is the relevance of specifying a tool. – Indrajeet Aug 27 '14 at 19:31
2

You can actually add the Tools under "Tool Locations" and just choose the tool from the drop-down list that you added in Global Tool Configuration. I tested and it worked perfectly well with Maven Tool