0

I'm trying to push a zipped bundle on nexus, which our hosted Nexus doesn't accept. We're building a release based on a git tag-name, e.g. 1.0.0

Maven command in our Jenkinsfile:

... 
steps {
    sh "mvn -pl distribution deploy:deploy-file -Drevision=$TAG_NAME -DgroupId=com.group.project -DartifactId=project-bundled -Dversion=$TAG_NAME -Dpackaging=zip -Dfile=target/distribution-$TAG_NAME.zip -Durl=https://hosted.com/nexus/repositories/project-releases -DrepositoryId=project-releases"
}
...

Here's the output from Jenkins:

[INFO] 
[INFO] --------------------< com.group.project:distribution >---------------------
[INFO] Building Distribution 1.0.0
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-deploy-plugin:2.8.2:deploy-file (default-cli) @ distribution ---
[INFO] Uploading to project-releases: https://hosted.com/nexus/repositories/project-releases/com/group/project/project-bundled/1.0.0/project-bundled-1.0.0.zip
[INFO] Uploading to project-releases: https://hosted.com/nexus/repositories/project-releases/com/group/project/project-bundled/1.0.0/project-bundled-1.0.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  38.460 s
[INFO] Finished at: 2022-01-26T15:59:38Z
[INFO] ------------------------------------------------------------------------
[INFO] [jenkins-event-spy] Generated /home/jenkins/agent/workspace/sxp-50Hertz-SMB_1.0.0/sidesystem@tmp/withMavene19bbfdf/maven-spy-20220126-....log
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (default-cli) on project distribution: Failed to deploy artifacts: Could not transfer artifact com.group.project:project-bundled:zip:1.0.0 from/to project-releases (https://hosted.com/nexus/repositories/project-releases): transfer failed for https://hosted.com/nexus/repositories/project-releases/com/group/project/project-bundled/1.0.0/project-bundled-1.0.0.zip, status: 405 Method Not Allowed -> [Help 1]

Here's also the distributionManagement part in the pom.xml, but the usual mvn deploy command works

    <distributionManagement>
        <repository>
            <id>project-releases</id>
            <name>project-releases</name>
            <url>https://hosted.com/nexus/repository/project-releases</url>
        </repository>
        <snapshotRepository>
            <id>project-snapshots</id>
            <name>project-snapshots</name>
            <url>https://hosted.com/nexus/repository/project-snapshots</url>
        </snapshotRepository>
    </distributionManagement>
ndueck
  • 713
  • 1
  • 8
  • 27
  • It looks like the release you have defined already exists in your repository manager (Nexus)... releases are immutable. Apart from that you should use `mvn deploy` instead of `deploy:deploy-file` or alike... – khmarbaise Jan 26 '22 at 17:06
  • @khmarbaise Unfortunately it's not an already existing release. I've managed to make a zip file with maven, but didn't add it to the deploy goal. If you show how to do this, I'll take it as a valid answer here on stackoverflow. Using the deploy-file command was a bit strange, because i had to change the url for some reason (repositories instead of repository) – ndueck Jan 27 '22 at 09:07
  • 1
    The 405 likely means you’ve got the wrong repository URL. Note that the maven message has “repositories”, not “repository”, as it should: https://hosted.com/nexus/repositories/project-releases – rseddon Jan 27 '22 at 14:17
  • @rseddon If I use repository in the url I get an Authentication error 401. The credentials must be correct, because the usual deploy task works. – ndueck Jan 28 '22 at 10:34
  • 1
    @rseddon Your answer is correct. It was the URL, i just tried again and it worked. I think the last time I was getting the 401 error was because I was missing -DrepositoryId=... in the mvn deploy:deploy-file command. – ndueck Jan 28 '22 at 12:07

0 Answers0