在 Jenkins 管道中解析 pom.xml 文件
Parsing pom.xml file within a Jenkins pipeline
我正在尝试在 jenkins 管道插件中解析我的 pom.xml。我打算修改后存回去
我的问题是它给了我 "unclassified field java.lang.String version"
我的代码如下:
@NonCPS
groovy.util.Node getPom(path) {
new XmlParser().parseText(readFile(path)).version
}
node {
groovy.util.Node pomNode = getPom("pom.xml")
println pomNode
}
这里讨论了类似的问题:
为什么不使用(为此你需要管道实用程序步骤插件):
pom = readMavenPom file: 'pom.xml'
现在您可以访问 pom 中的所有数据(作为 Model
)。
我正在尝试在 jenkins 管道插件中解析我的 pom.xml。我打算修改后存回去
我的问题是它给了我 "unclassified field java.lang.String version"
我的代码如下:
@NonCPS
groovy.util.Node getPom(path) {
new XmlParser().parseText(readFile(path)).version
}
node {
groovy.util.Node pomNode = getPom("pom.xml")
println pomNode
}
这里讨论了类似的问题:
为什么不使用(为此你需要管道实用程序步骤插件):
pom = readMavenPom file: 'pom.xml'
现在您可以访问 pom 中的所有数据(作为 Model
)。