Failed to deploy artifacts using maven, error code 409
Asked Answered
W

2

4

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.

Weller answered 2/12, 2019 at 7:26 Comment(2)
Is the pom file shared in your question complete? I could not repositories node in it. BTW, I could not get any useful info from the error log, it just show error status code 409 without any other useful info, so I could not give any useful suggestion, try to share the debug log, or any other info about this issue.Smolder
I will post more detailed information here.Weller
B
3

In Azure Devops, you cannot reuse version numbers in an artifact repository feed. For instance, if you had already deployed v2.0, and deleted it from the feed, you will get an HTTP 409 error if you try to redeploy a v2.0 artifact with the same name at any time in the future.

Brochure answered 24/11, 2020 at 20:12 Comment(0)
V
2

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://mcmap.net/q/941333/-maven-deploy-changed-artifacts-only. Again I am not sure how to enable this on Azure.

I have asked this as a separate question of my own

Vigilant answered 9/6, 2020 at 22:54 Comment(1)
appending -SNAPSHOT did it for me. Faced this problem while pushing github packages via workflowMensch

© 2022 - 2024 — McMap. All rights reserved.