Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkinsfile error- java.lang.NoSuchMethodError: No such DSL method 'withMaven' found among steps

I am currently trying to implement pipeline in jenkins using jenkinsfile and i am executing a maven project on windows machine. I am creating a pipeline job in jenkins and i have checked in this file in my github repository and when i am running the job in jenkins , i am getting following error.

My jenkinsfile:

    pipeline {
        agent any
        stages {
            stage('Compile stage') {
                steps {
                    maven(maven : 'Maven_3.5.2'){
                        bat "mvn clean compile"
                }
            }
        }

             stage('testing stage') {
                 steps {
                    maven(maven : 'Maven_3.5.2'){
                        bat "mvn test"
                }
            }
        }

              stage('deployment stage') {
                  steps {
                    maven(maven : 'Maven_3.5.2'){
                        bat "mvn deploy"
                }
            }
        }

      }

    }

I am getting below error when i am running it through jenkins job- Jenkins error:

java.lang.NoSuchMethodError: No such DSL method 'withMaven' found among steps [archive, bat, build, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo, emailext, emailextrecipients, envVarsForTool, error, fileExists, getContext, git, input, isUnix, library, libraryResource, load, mail, milestone, node, parallel, powershell, properties, pwd, readFile, readTrusted, resolveScm, retry, script, sh, sleep, stage, stash, step, svn, timeout, timestamps, tm, tool, unarchive, unstash, validateDeclarativePipeline, waitUntil, withContext, withCredentials, withDockerContainer, withDockerRegistry, withDockerServer, withEnv, wrap, writeFile, ws] or symbols [all, allOf, always, ant, antFromApache, antOutcome, antTarget, any, anyOf, apiToken, architecture, archiveArtifacts, artifactManager, authorizationMatrix, batchFile, booleanParam, branch,

Any help?

like image 561
Abhishek Somani Avatar asked Nov 01 '17 05:11

Abhishek Somani


1 Answers

This means you don't have withMaven as an available DSL method. Most of the time this means you don't have a plugin installed. In this case, the Pipeline Maven Integration plugin is required. https://plugins.jenkins.io/pipeline-maven/

like image 185
Rob Hales Avatar answered Sep 22 '22 09:09

Rob Hales