28

我正在开发一个用于 Jenkins 2.0 的 Jenkinsfile。该readMavenPom方法无法识别。我是否缺少一些配置来使其可用?

我的詹金斯文件:

node {
  stage 'Checkout'
  checkout scm
  env.PATH = "${tool 'maven-3'}/bin:${env.PATH}"
  stage 'Build'
  def pom = readMavenPom file: 'pom.xml'
  echo "${pom}"
  sh "mvn -DskipTests=true verify"
}

运行时,我收到以下错误:

java.lang.NoSuchMethodError: No such DSL method 'readMavenPom' found among
[AWSEBDeployment, archive, bat, build, catchError, checkout, deleteDir, dir, echo,
emailext, error, fileExists, git, input, isUnix, load, mail, node, parallel,
properties, pwd, readFile, retry, sh, slackSend, sleep, stage, stash, step, svn,
timeout, tool, unarchive, unstash, waitUntil, withCredentials, withEnv, wrap,
writeFile, ws]
4

2 回答 2

79

我需要安装pipeline-utility-steps插件。

于 2016-05-12T22:15:42.367 回答
0

在使用此步骤之前,请注意 writeMavenPom/readMavenPom 文档中的以下内容:

避免使用此步骤并阅读 MavenPom。最好使用 sh 步骤来运行 mvn 目标

https://www.jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#writemavenpom-write-a-maven-project-file

于 2020-11-23T22:46:56.517 回答