如何在 Azure Artifacts 中更新具有相同版本号的 Maven 依赖项
How to update a maven dependency with a same version number in Azure Artifacts
我们将 Maven 私有存储库 Nexus 更改为 Azure Artifacts。
当我们上传一个带有某个版本的私有 Maven 依赖项时,它会告诉我们以下信息:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
(default-deploy) on project HmapBasic: Failed to deploy artifacts:
Could not transfer artifact com.hand:HmapBasic:pom:3.0.3-RELEASE
from/to dev-azure-com-kohlerdevops-konnect-unified
(https://pkgs.dev.azure.com/KohlerDevOps/_packaging/Konnect-Unified/maven/v1/):
Failed to transfer file:
https://pkgs.dev.azure.com/KohlerDevOps/_packaging/Konnect-Unified/maven/v1/com/hand/HmapBasic/3.0.3-RELEASE/HmapBasic-3.0.3-RELEASE.pom.
Return code is: 409
我搜索了代码409错误。这意味着我们已经上传了这个版本的依赖,我们不能再上传了。
我们希望在不改变版本的情况下使用新的依赖覆盖旧的(因为如果我们改变版本,我们所有的项目都需要改变pom.xml)
我们如何在 Azure Artifacts 中做到这一点?
How to update a maven dependency with a same version number in Azure Artifacts
恐怕您必须更改 pom.xml,我理解这对您来说是多么令人沮丧。但这是Azure Artifacts为了保证构建结果的正确性而特意设计的。
查看文档:Understand immutability of packages.
Once you publish a particular version of a package to a feed, that
version number is permanently reserved. You cannot upload a newer
revision package with that same version number, or delete it and
upload a new package at the same version.
这样设计的原因:
That because many package clients, including NuGet, keep a local cache
of packages on your machine. Once a client has cached a particular
package@version, it will return that copy on future install/restore
requests. If, on the server, you replace package@version (rev 1) with
a new package@version (rev 2), the client is unable to tell the
difference. the client still use the old version in cache. This can lead to indeterminate build results from
different machines.
So we could not overwrite all packages that have already been
uploaded, even we could not delete them and re-uploaded. To resolve
this issue, the only way is that upload the packages with a new
version.
查看我的 了解更多信息。
希望对您有所帮助。
我刚刚在 Azure DevOps 上进行了测试,如果您使用 "SNAPSHOT" 后缀,它将覆盖之前的 package/artifact。例如2.0.0-SNAPSHOT
.
我们将 Maven 私有存储库 Nexus 更改为 Azure Artifacts。 当我们上传一个带有某个版本的私有 Maven 依赖项时,它会告诉我们以下信息:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project HmapBasic: Failed to deploy artifacts: Could not transfer artifact com.hand:HmapBasic:pom:3.0.3-RELEASE from/to dev-azure-com-kohlerdevops-konnect-unified (https://pkgs.dev.azure.com/KohlerDevOps/_packaging/Konnect-Unified/maven/v1/): Failed to transfer file: https://pkgs.dev.azure.com/KohlerDevOps/_packaging/Konnect-Unified/maven/v1/com/hand/HmapBasic/3.0.3-RELEASE/HmapBasic-3.0.3-RELEASE.pom. Return code is: 409
我搜索了代码409错误。这意味着我们已经上传了这个版本的依赖,我们不能再上传了。 我们希望在不改变版本的情况下使用新的依赖覆盖旧的(因为如果我们改变版本,我们所有的项目都需要改变pom.xml)
我们如何在 Azure Artifacts 中做到这一点?
How to update a maven dependency with a same version number in Azure Artifacts
恐怕您必须更改 pom.xml,我理解这对您来说是多么令人沮丧。但这是Azure Artifacts为了保证构建结果的正确性而特意设计的。
查看文档:Understand immutability of packages.
Once you publish a particular version of a package to a feed, that version number is permanently reserved. You cannot upload a newer revision package with that same version number, or delete it and upload a new package at the same version.
这样设计的原因:
That because many package clients, including NuGet, keep a local cache of packages on your machine. Once a client has cached a particular package@version, it will return that copy on future install/restore requests. If, on the server, you replace package@version (rev 1) with a new package@version (rev 2), the client is unable to tell the difference. the client still use the old version in cache. This can lead to indeterminate build results from different machines.
So we could not overwrite all packages that have already been uploaded, even we could not delete them and re-uploaded. To resolve this issue, the only way is that upload the packages with a new version.
查看我的
希望对您有所帮助。
我刚刚在 Azure DevOps 上进行了测试,如果您使用 "SNAPSHOT" 后缀,它将覆盖之前的 package/artifact。例如2.0.0-SNAPSHOT
.