Failed to deploy artifacts using maven, error code 409

Deadly 提交于 2020-06-17 03:52:48

问题


I am using azure devops, and trying to building code and upload using maven, but i am getting following error message.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file 
(default-cli) on project ojdbc7: 

com.huber.abc:ojdbc7:jar:2.0 from
to dev-azure-com-abc-devops-abc-artifacts (https://pkgs.dev.azure.com/ABC-DevOps/_packaging/abc- 
Artifacts/maven/v1):

Failed to transfer file 

https://pkgs.dev.azure.com/abc-DevOps/_packaging/abc- 
Artifacts/maven/v1/com/huber/abc/ojdbc7/2.0/ojdbc7-2.0.jar with status code 409 -> [Help 1]Failed to 
deploy artifacts: 

Could not transfer artifact

I had found one question thread like similar issue. As per that link don't use snapshot but use release. So I am adding my pom.xml file here for the reference.

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.myorg.abc</groupId>
  <artifactId>ojdbc7</artifactId>
  <version>2.0</version>
</project>

I don't know how to resolve this issue. I have seen many versions of error 409. But it seems my issue is different, please guide me.


回答1:


This is not a complete answer but it may help a little. I am new to both Azure Dev Ops and Maven so please forgive and correct any mistakes in the comments. I have repeated some things its clear the OP knows to make the answer clearer to others.

Maven allow you to deploy two kinds of artifact:

  1. SNAPSHOTS

    • A snapshot is a development version of a package.
    • Snapshots have the suffix -SNAPSHOT. E.g. 1.2.0-SNAPSHOT
    • SNAPSHOTS are mutable. A deploy operation can replace a SNAPSHOT with a new version (more recent development versions can replace development versions)
  2. RELEASES

    • Any version not ending in the suffix -SNAPSHOT is considered a release version.
    • Releases are immutable. A deploy operation will fail if the release has already been deployed to the repository.

409 = Resource Conflict

This can mean

  • The artifact has already been published and cannot be overwritten

  • The artifact could not be published because it was the wrong type. For example publishing a release to a repository that only accepts snapshots or publishing a snapshot to a repository that only accepts releases

See also: How to update a maven dependency with a same version number in Azure Artifacts (you can't for a release)

I am not sure how to tell maven that its okay for the deployment to fail if the artifact already exists. The obvious and wrong hack (in Linux) is:

mvn deploy || /bin/true

I'm not sure what the equivalent is in Azure or if there is an option to maven that makes it behave this way. This hack is bad because it will report the deployment step as successful if it has failed for another reason.

There is a plugin https://github.com/chonton/exists-maven-plugin that does this see https://stackoverflow.com/a/53623937/1569204. Again I am not sure how to enable this on Azure.

I have asked this as a separate question of my own



来源:https://stackoverflow.com/questions/59134329/failed-to-deploy-artifacts-using-maven-error-code-409

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!