Skip to content

Auto maven plugin does not consider versions-maven-plugin when it's in parent pom #2257

Open
@neloydas

Description

@neloydas

Describe the bug

I have a maven project A that is with packaging pom and is the parent repo. Also I have a microservice B(maven project) which is the child of A. Now if the versions-maven-plugin is specified in project A and not project B, auto shipit command fails to detect it from the parent. So it falls back to manually modifying the pom and increment the version. But the issue with manual version change is, it changes the version for both the version tag inside (project A) as well as the normal version of B in B's pom. But I don't want to increment the parent project's version. I want to release only B.

To Reproduce

  1. Create two maven projects A and B. A is parent for B. They are in separate repo and released separately. Put versions-maven-plugin in repo A.
  2. Download the npm dependencies like auto, @auto-it/maven etc.
  3. Configure autorc file for the B project.
  4. Run the auto shipit command from project B and try to release a new patch version.
  5. It'll try to increase patch version for parent A and B inside B's POM.xml

Expected behavior

It should only increase version for project B and not change the version inside <parent> tag in B's POM.xml

Environment information:

I am running this mostly inside enterprise Jenkins while getting the issue. While running locally it fails on other problems which is irrelevant.

+ npx auto info

(node:449) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.

(Use `node --trace-warnings ...` to show where the warning was created)

Environment Information:

"auto" version: v10.37.6
"git"  version: v2.30.0
"node" version: v16.13.2
GHE version:    v3.5.3

Project Information:

��� Repository:      owner/some-repo (���https://github.systems.***/owner/some-repo ���)
��� Author Name:     Neloy Das
��� Author Email:    [email protected]
��� Current Version: v1.1.1
��� Latest Release:  v1.1.0 (���https://github.systems.***/owner/some-repo/releases/tag/v1.1.0���)
��� Labels configured on GitHub project 

GitHub Token Information:

��� Token:            [Token starting with ghp_]
��� Repo Permission:  admin
��� User:             user
��� API:              https://github.systems.***/api/v3 (���https://github.systems.***/api/v3���)
��� Enabled Scopes:   repo
��� Rate Limit:       9978/10000

Additional context

I was checking the index.ts inside maven folder and found that it is checking if the versions-maven-plugin exists or not by just parsing the POM. with this /project/build/plugins/plugin/artifactId[normalize-space(text())='versions-maven-plugin']. My suggestion would be to parse the maven effective pom not just the POM.xml file. Because the versions-maven-plugin can be located in parent pom.

So run this command first : mvn help:effective-pom -Doutput=effective-pom.xml. The output=effective-pom.xml part stores the effective pom in a file of that name. Then we can check that file instead to see if there's any versions-maven-plugin exists or not.

Here's the autorc file if you need it. I am using enterprise jenkins, github and jira here. The links are purposefully changed to remove company information.

{
  "githubApi": "https://github.systems.***/api/v3",
  "githubGraphqlApi": "https://github.systems.***/api",
  "shipit": {
    "prerelease": false,
    "message": "Update CHANGELOG.md with release description [skip ci]",
    "noChangelog": false,
    "onlyGraduateWithReleaseLabel": false
  },
  "comment": {
    "edit": true,
    "delete": true
  },
  "plugins": [
     [
        "maven", {
          "mavenCommand": "/usr/lib/maven/3.6.1/bin/mvn",
          "mavenOptions": ["-Dmaven.test.skip=true"],
          "mavenReleaseGoals": ["deploy"],
          "mavenSettings": "mvn-settings.xml"
        }
     ],
     [ "jira", "https://jira.prd.cloud.***/browse" ],
     "released"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions