You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除Azure DevOps上传Maven SNAPSHOT至Artifactory的版本后缀

解决方案:去除Azure DevOps部署Maven快照包到JFrog时的时间戳后缀

你遇到的文件名自动追加时间戳后缀是Maven快照版本的默认行为,由Maven部署规则和JFrog Artifactory仓库配置共同作用,可通过以下方案解决:


方案1:调整JFrog Artifactory仓库全局配置(推荐)

该配置优先级最高,调整后所有上传到对应仓库的SNAPSHOT版本制品都会自动使用不带时间戳的命名格式:

  • 登录JFrog Artifactory管理后台,依次进入「Administration」→「Repositories」→「Repositories」列表
  • 找到你当前使用的Maven仓库(你配置中填写的jfrog-maven-repo),点击进入编辑页
  • 找到页面中的「Maven Settings」配置项,关闭「Unique Snapshot Version」选项后保存即可

方案2:调整流水线任务配置

你当前的配置不生效存在两个核心问题:

  1. 任务的goals参数设置为install,-DuniqueVersion=false是Maven deploy阶段的专属参数,install阶段不会读取该配置
  2. Maven 3+版本需要额外适配参数才能生效

调整后的流水线任务示例:

- task: ArtifactoryMaven@2
  inputs:
    mavenPomFile: 'pom.xml'
    goals: 'deploy' # 替换为deploy目标触发部署流程
    artifactoryResolverService: 'jfrog-service-connection'
    targetResolveReleaseRepo: 'jfrog-maven-repo'
    targetResolveSnapshotRepo: 'jfrog-maven-repo'
    artifactoryDeployService: 'jfrog-service-connection'
    targetDeployReleaseRepo: 'jfrog-maven-repo'
    targetDeploySnapshotRepo: 'jfrog-maven-repo'
    collectBuildInfo: true
    options: '-Dmaven.deploy.snapshotTimestampSuffix= -DuniqueVersion=false' # 追加Maven3+适配参数
  displayName: 'Build and Deploy to repo'

方案3:发布为正式Release版本

如果你期望的最终制品不需要保留SNAPSHOT标识,可以在构建前先将pom文件中的版本号修改为不带-SNAPSHOT的正式版本(如0.0.1),后续上传的制品会自动按照my-artifact-0.0.1.jar的格式命名,不会追加任何后缀。


内容的提问来源于stack exchange,提问作者Pronomita Dey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 04:48:02