Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get inherited groupId with readMavenPom

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.

like image 329
dcalap Avatar asked Mar 07 '19 15:03

dcalap


1 Answers

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.

like image 194
khmarbaise Avatar answered Nov 15 '22 06:11

khmarbaise