I have a question concerning readMavenPom (Link to doc) utility from Jenkins pipelines.
I have a project with a pom.xml where no groupId is defined but this pom.xml has a parent pom with a a defined groupId. (It could happen that, even this parent doesn't have a defined groupId and is the parent.parent the one that has it).
Is there a way to get the, let's say, effective groupId in an elegant way?
I'm currently getting null with the getGroupId() method (or property accessor .groupId)
NOTE: With elegant way I mean, not looping into parents and checking if groupId is not null.
Thanks in advance.
You could simply use the maven-help-plugin:evaluate goal via command line which can give you what you need.
The following will exactly extract the groupId of the project and will handle all the things based on your inheritance part.
mvn help:evaluate -Dexpression=project.groupId -q -DforceStdout
This could be done in a separate stage step of the Jenkins Pipeline.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With