Charles Morin
Charles Morin

Reputation: 1447

Accessing parent POM properties from Jenkinsfile

I have a Spring application that is built using Maven. Jenkins Declarative pipeline is being used for achieving CI/CD.

I want my Jenkinsfile to be as generic as possible, leveraging what's already available from the POM along with its parent POM. We use a custom Super POM to centralize metadata such as our Artifactory repositories (distributionManagement />), SonarQube servers and some other valuable properties.

I'm already using readMavenPom().getParent().getGroupId() to fetch our company's standard groupId, along with readMavenPom().getArtifactId(), readMavenPom().getVersion() and readMavenPom().getPackaging().

I'd like to access the metadata so I can use it for the pipeline step that publishes binaries to Artifactory.

Looking at the Parent class, I don't see any getter for the distributionManagement tag. I do see it under ModelBase though.

How can I access those details from the Jenkinsfile?

Thank you

Upvotes: 2

Views: 3371

Answers (1)

khmarbaise
khmarbaise

Reputation: 97487

The point is the inheritance solution is only done in Maven itself but not in Jenkins. You might try to get this via mvn -N help:effective-pom -Doutput=result.xml and give a parameter to readMavenPom('result.xml')

Upvotes: 6

Related Questions