'ERROR: Could not find specified Maven installation 'maven_5_6_2'

I have a Jenkinsfile (see below) which runs a number of commands. I have the 'Pipeline Maven Integration' plugin installed in my Jenkins server (I have version 3_10_0 of Pipeline Maven Integration installed in Jenkins). But when I try to run my pipeline I get the error below in the console. Am I missing something? Is the error complaining about the Jenkins Maven plugin or the version of Maven in my Java solution?

Jenkinsfile:-

pipeline {
    agent any
    
    stages {
        stage ('Compile Stage') {
            steps {
                withMaven(maven: 'maven_3_8_4') {
                    sh 'mvn clean install'
                }
            }
        }
        
        stage ('Test Stage') {
            steps {
                withMaven(maven: 'maven_3_8_4') {
                    sh 'mvn test'
                }
            }
        }
        stage ('Cucumber Reports') {
            steps {
                cucumber buildStatus: "UNSTABLE",
                fileIncludePattern: "**/cucumber-report.json",
                jsonReportDirectory: 'target'
            }
        }
    }
}

Error in console:-

ERROR: Could not find specified Maven installation 'maven_3_10_0'. Finished: FAILURE

Further information I have version 3.8.4 of Maven installed on the machine running the Jenkins server. I have also updated the Jenkins global tools config to reference version 3.8.4 of Maven, bit I still get the same error when running the pipeline.



Solution 1:[1]

I worked it out, the reference should have been as follows in the Jenkinsfile (as this is what is n my global tools):- enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ED209