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

标签 maven jenkins jenkins-pipeline

我目前正在尝试使用 jenkinsfile 在 jenkins 中实现管道,并且我正在 Windows 机器上执行一个 maven 项目。我正在 jenkins 中创建一个管道作业,我已经在我的 github 存储库中 checkin 了这个文件,当我在 jenkins 中运行该作业时,出现以下错误。

我的 Jenkins 文件:

    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"
                }
            }
        }

      }

    }

当我通过 jenkins 工作运行它时,我遇到了以下错误-
Jenkins 错误:

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,



有什么帮助吗?

最佳答案

这意味着您没有 withMaven作为一种可用的 DSL 方法。大多数情况下,这意味着您没有安装插件。在这种情况下,需要 Pipeline Maven 集成插件。 https://plugins.jenkins.io/pipeline-maven/

关于maven - Jenkinsfile 错误 - java.lang.NoSuchMethodError : No such DSL method 'withMaven' found among steps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47048960/

相关文章:

gwt - 将gwt项目转换为maven gwt项目

java - 在 Jenkinsfile 中使用 Publish Over SSH 时出现 NotSerializedException

iis - MSDeploy - 将文件复制到 iis 应用程序的子文件夹的同步命令

jenkins - Groovy 读取 yaml 文件返回数组

grails - 如何确定 Jenkins 管道中的当前操作系统

java.lang.NoClassDefFoundError : javax/validation/Validator

java - "java could not find the main class"和 "could not read maven project"

java - 如何运行 java 应用程序并使用其输出来运行 Maven Artifact ?

jenkins - jtl 文件未在 jenkins 中为 jmeter 解析

jenkins - 防止 Jenkins 在首次运行/种子作业时构建多分支管道的所有分支?