Varun Kancharla
Varun Kancharla

Reputation: 117

Jenkins pipeline error: Tool type maven does not have an install

I'm using Groovy script to deploy application to server. I want to install latest version of Maven before project gets built using below script.

    pipeline {
      agent any

      tools {
          maven "Maven 3.6.3"    
      }
      ....
      stages {
      ....
      }
    }

I get this below exception when I run the job.

Running in Durability level: MAX_SURVIVABILITY org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 15: Tool type "maven" does not have an install of "Maven 3.6.3" configured - did you mean "Maven-3.3.3"? @ line 15, column 15. maven "Maven 3.6.3"

1 error

    at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
    at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
    at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
    at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142)
    at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:337)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:428)
Finished: FAILURE

Can anyone suggest what I'm making wrong?

Upvotes: 5

Views: 6401

Answers (4)

Recep Karayiğit
Recep Karayiğit

Reputation: 1

For newer versions of Jenkins, the required Maven configuration can be found under Dashboard > Manage Jenkins > Tools. In the Maven section, select the desired version and ensure that the name you assign to the Maven version matches exactly with the name in the tool section. The name must be an exact match.

Upvotes: 0

Severiano Cuellar
Severiano Cuellar

Reputation: 84

Both , Name (in Maven installations) and code (Pipeline script) should match. In my case:

Name should match your code in Pipeline script

Code should match Name of Maven

Upvotes: 0

Ramkumar
Ramkumar

Reputation: 166

I tried the below steps and it worked for me.

  1. Goto Dashboard > Manage Jenkins > Global Tools Configuration. Then, click on Add Maven and mentioned a name and maven version. In my case, I named it as 3.8.5.

Apply the changes

enter image description here

In the pipeline code, mentioned tools { maven 'NAME_AS_IN_GLOBAL_CONFIGURATION' }

pipeline {
    agent { label 'main' }
    

    tools {
        maven '3.8.5' 
       // This is the name as in Global Configuration
    }
    // ... stages ...///
}

Upvotes: 7

Sandesh Udoshi
Sandesh Udoshi

Reputation: 1

I tried the following method and it worked for me. first i changed the maven version to '3.8.6' in Global Tool Configuration

And changed same in the code with maven '3.8.6' shown below

pipeline { agent any

tools { maven '3.8.6' } stage { /// }

Upvotes: 0

Related Questions