Jenkins 将工件部署到 Artifactory。 maven-metadata.xml 显示不正确的发布版本并且不显示快照版本

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

我是 Jenkins 和 Artifactory 的新手,我一直无法解决这个问题。我正在使用 Jenkins 2.32.1、Artifactory 4.14.0、Jenkins Artifactory 插件 2.9.0 和 Maven 2。我正在使用 Jenkins 管道进行构建。

这是我的 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'
    }
}

我的 Artifactory 仓库看起来像:

这是我的 pom.xml 快照版本的片段:

<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>

这里是 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>

我的问题是 maven-metadata.xml 文件将快照版本列为其最新发布版本,而某些东西(Artifactory?)无法识别 11-20170126.182450-1 版本实际上是快照版本。

当此 repo 在我的其他项目的 pom.xml 中被列为依赖项时,这会产生问题。当它试图从这个 repo 获取最新版本时,它错误地尝试获取快照版本 (11-...) 而不是发布版本 (8)。

提前致谢!我感谢对这个问题的任何建议或见解。

@Tunaki 在我的问题的评论中回答了我的问题。我在 pom.xml 中使用范围来引用 post 中提到的存储库中的工件。我切换到使用确切的版本号,现在它工作正常。