简体   繁体   中英

Jenkins deploying artifacts to Artifactory. maven-metadata.xml shows incorrect version for release and does not show versions for snapshot

I am new to Jenkins and Artifactory and I have been unable to resolve this issue. I am using Jenkins 2.32.1, Artifactory 4.14.0, the Jenkins Artifactory plugin 2.9.0, and Maven 2. I am building using the Jenkins pipeline.

Here is my jenkinsfile :

node('default') {
    try{
        def server = Artifactory.newServer url: 'https://artifactory.com/artifactory', credentialsId: 'MYCREADENTIALS'
        def rtMaven = Artifactory.newMavenBuild()


        stage('Checkout') {
            checkout myProject
        }

        stage('Artifactory configuration') {
            rtMaven.tool = 'Default'
            rtMaven.resolver server: server, releaseRepo: 'my-repo-all', snapshotRepo: 'my-repo-all'
            rtMaven.deployer server: server, releaseRepo: 'my-repo-local', snapshotRepo: 'my-repo-local'
        }

        stage('Clean') {
            rtMaven.run pom: 'pom.xml', goals: 'clean '
        }

        stage('Install') {
            def buildInfo = rtMaven.run pom: 'pom.xml', goals: 'install '
            server.publishBuildInfo buildInfo
        }

    } catch (err) {
        echo "Caught: $err"
        currentBuild.result = 'FAILURE'
    }
}

My Artifactory repo looks like:

  • my-repo-local
    • ....
    • 8 (a release version)
    • 11-20170126.182450-1 (a snapshot version)
    • maven-metadata.xml

Here is a snippet from my pom.xml of the snapshot version:

<groupId>com.my.group</groupId>
<artifactId>my-project-local</artifactId>
<packaging>jar</packaging>
<version>11-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>my description</description>

Here is the mavan-metadata.xml :

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>com.my.group</groupId>
  <artifactId>my-project-local</artifactId>
  <version>11-20170126.182450-1</version>
  <versioning>
    <latest>11-20170126.182450-1</latest>
    <release>11-20170126.182450-1</release>
    <versions>
      <version>4</version>
      <version>5</version>
      <version>6</version>
      <version>7</version>
      <version>8</version>
      <version>11-20170126.173903-1</version>
      <version>11-20170126.182450-1</version>
    </versions>
    <lastUpdated>20170126192233</lastUpdated>
  </versioning>
</metadata>

My issue is that the maven-metadata.xml file is listing the snapshot version as its latest release version, and something (Artifactory?) is not recognizing the 11-20170126.182450-1 version is actually a snapshot version.

This creates issues when this repo is listed as a dependency in the pom.xml of my other projects. When it tries to grab the latest version from this repo, it incorrectly tries to grab the snapshot version (11-...) rather than the release version (8).

Thank you in advance! I appreciate any advice or insight into this problem.

My question was answered in the comments of my question by @Tunaki. I was using ranges in my pom.xml to reference the artifacts from the repository mentioned in my post. I switched to using the exact version number and it is working correctly now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM