Nicholas
Nicholas

Reputation: 1229

Jenkins uses different version of Maven than cmd

First I installed Maven version 3.0.5 on our build system and then I upgraded it to 3.6.0 following this guide https://linuxize.com/post/how-to-install-apache-maven-on-centos-7/ . Using the cmdline on the system executing:

mvn -v

I always get 3.6.0 as the version. But when executing the same command in a Jenkins job I get 3.0.5 . So somewhere it looks like it still refers to the older version. But I have no clue where. Any ideas how to check this?

Upvotes: 1

Views: 546

Answers (1)

Lesiak
Lesiak

Reputation: 25966

The version you see in the shell depends on your PATH variable.

Jenkins can handle multiple installations of maven. To configure it:

  • Open the Jenkins dashboard.
  • Go to Manage Jenkins.
  • Go to Global Tool Configuration
  • Go to the Maven section and click Maven installations

When adding a new installation, you have 2 options:

  • install a selected version automatically
  • use existing installation on your system

Then, when configuring a project in jenkins, you can select one of the configured installations.

  • For Maven Project under Build / Maven Version
  • For Freestyle project under Build Steps / Build / Invoke top level maven targets / Maven Version

Upvotes: 2

Related Questions