Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins: no tool named M3 found

Setting up a Pipeline build in Jenkins (Jenkins 2.7.2), copying the sample script for a git-based build gives: "no tool named M3 found". The relevant line in the Pipeline script is:

def mvnHome = tool 'M3'
like image 938
hack_on Avatar asked Aug 31 '16 23:08

hack_on


2 Answers

You need to have Maven installation available to do builds. You can configure using Global Tool Configuration and give name as 'M3'

def mvnHome = tool 'M3'

It says M3 is installed and assigns the return value to the mvnHome

like image 159
ravthiru Avatar answered Sep 19 '22 12:09

ravthiru


make sure that the maven installation is configured in hudson.tasks.Maven.xml as below with name you want (I have MAVEN3 below),

cat /var/lib/jenkins/hudson.tasks.Maven.xml

<?xml version='1.0' encoding='UTF-8'?>
<hudson.tasks.Maven_-DescriptorImpl>
  <installations>
    <hudson.tasks.Maven_-MavenInstallation>
      <name>MAVEN3</name>
      <home>/usr/share/apache-maven/</home>
      <properties/>
    </hudson.tasks.Maven_-MavenInstallation>
  </installations>
</hudson.tasks.Maven_-DescriptorImpl>

Followed by jenkins restart

systemctl restart jenkins.service

It can be verified in UI as well,

maven installation name

Then, same variable can be used in pipeline script.

node {
   def mvnHome
   stage('Preparation') {
      git url: 'https://github.com/prayagupd/eccount-rest.git', branch: 'REST-API-load-balancing'
      mvnHome = tool 'MAVEN3'
   }
   stage('Build') {
      sh "'${mvnHome}/bin/mvn' -Dmaven.test.failure.ignore clean package"
   }
   stage('Results') {
      junit '**/target/surefire-reports/TEST-*.xml'
      archive 'target/*.jar'
   }
}
like image 43
prayagupa Avatar answered Sep 22 '22 12:09

prayagupa