Reputation: 8988
After we fetch POM model like described in Krzysztof Krasoń's answer in extract pom version in a jenkins pipeline. Call to pom.version returns the fully qualified name of the artifact and not just the version.
For example
@NonCPS
def version() {
pom = readMavenPom file: 'pom.xml'
pom.version
}
for
<groupId>com.test.app</groupId>
<artifactId>app</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
will produce
com.test.app:app:pom:1.0.0-SNAPSHOT
Is there a way to return just the version part from returned Model without doing any String manipulation?
Upvotes: 0
Views: 1823
Reputation: 10395
You should not call regular (CPS-transformed) methods, or Pipeline steps inside @NonCPS
methods because they requires CPS-transformation.
See more in README.md.
Upvotes: 1