Pom.xml file analysis in the Jenkins pipeline

I am trying to parse my pom.xml in a jenkins pipeline plugin. I intend to change it and save it back.

My problem is that it gives me the "unclassified field java.lang.String version"

My code is as follows:

@NonCPS groovy.util.Node getPom(path) { new XmlParser().parseText(readFile(path)).version } node { groovy.util.Node pomNode = getPom("pom.xml") println pomNode } 

A similar issue was discussed here: Parsing an XML file as part of a Jenkins project

+5
source share
1 answer

Why not use (for this you need the pipeline utility steps plugin):

 pom = readMavenPom file: 'pom.xml' 

Now you have access to all the data in pom (like Model ).

+7
source

All Articles