我正在编写一个Jenkins文件,用于Jenkins 2.0。无法识别readMavenPom
方法。我是否缺少某些配置以使其可用?
我的Jenkinsfile:
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]
3条答案
按热度按时间mrwjdhj31#
安装
pipeline-utility-steps
插件gwo2fgha2#
在使用此步骤之前,请注意writeMavenPom/readMavenPom文档中的以下内容:
避免使用此步骤并readMavenPom。最好使用sh步骤来运行mvn目标
https://www.jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#writemavenpom-write-a-maven-project-file
kpbpu0083#
1.使用以下命令读取声明性管道中的整个pom.xml:
1.对于pom.xml中的特定属性,请使用具有标记层次结构的相同命令:
项目.属性.子属性........等等