Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-45563

Jenkins Maven parsing POMs does not respect overridden versions for imports

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • maven-plugin
    • None
    • CloudBees Jenkins Enterprise 2.46.2.1-rolling
      maven plugin 2.14
      Maven 3.3.9
      JDK 7

      We have a POM like this:

      <project>
        ...
        <properties>
          <xyz.version>1.0.2-SNAPSHOT<xyz.version>
        </properties>
      
        <dependencyManagement>
          <dependencies>
            <dependency>
              <groupId>com.example.mygroupId</groupId>
              <artifactId>xyz</artifactId>
              <version>${xyz.version}</version>
              <type>pom</type>
              <scope>import</scope>
            </dependency>
          </dependencies>
        </dependencyManagement>
        ...
      </project>

      and a Jenkins Maven Job with goals "-U clean deploy -Dxyz.version=$XYZ_VERSION".

      So we want to set the version of the imported POM from outside (with a build parameter). Unfortunately, the Jenkins build always tries to load the version specified in the POM (1.0.2-SNAPSHOT) during the "Parsing POMs step" (after log outpout "Parsing POMs" but before starting the actual maven build with the specified goals). So I guess the "Parsing POMs" step (whatever it does) does not respect the version specified in the goals (value of variable "XYZ_VERSION").
      This lets the build fail often because we regularly delete SNAPSHOTS from the repository if there is a newer SNAPSHOT and then this "Parsing POMs" step cannot find the version in the POM anymore ("Non-resolvable import POM" error).

      As a workaround we just now specified a non-SNAPSHOT version (e.g. "1.0.2") in the POM for "xyz.version". Then the log output is like:

      ...
      Parsing POMs
      ...
      Downloaded artifact http://nexus/content/groups/public/com/example/mygroupId/xyz/1.0.2/xyz-1.0.2.pom
      ...
      Executing Maven:  -B -f .../pom.xml -gs /tmp/global-settings1782219487899455358.xml -U clean deploy -Dxyz.version=1.0.3-SNAPSHOT
      ...
      [INFO] Downloaded: http://nexus/content/groups/public/com/example/mygroupId/xyz/1.0.3-SNAPSHOT/xyz-1.0.3-SNAPSHOT.pom
      

      So, the build works and uses the correct version (1.0.3-SNAPSHOT), but I don't know what it does with the wrong version (1.0.2) that is downloaded before the actual maven build.

      Thanks for your help.

            Unassigned Unassigned
            svenackermann Sven Ackermann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: