Matej
Matej

Reputation: 8988

Jenkinsfile and POM version

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

Answers (1)

Vitalii Vitrenko
Vitalii Vitrenko

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

Related Questions