6

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.

3
  • Hi, what do you need the groupId for?
    – hakamairi
    Commented Mar 8, 2019 at 8:32
  • probably he needs to do something doogey with it..... Commented Feb 20, 2020 at 17:06
  • Anyway that'a bug to open cause readMavenProject should evaluate the actual project and not the xml content.... Commented Feb 20, 2020 at 17:06

1 Answer 1

2

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.