3
votes

My versions:

  • Maven 3.0.4
  • Jenkins 1.499
  • Nexus 2.2
  • maven-release-plugin 3.2
  • jdk 1.6
  • AIX 6.1

settings.xml

<server>
    <id>snapshots</id>
    <username>deploy</username>
    <password>pass123</password>
</server> 
<server>
        <id>releases</id>  
        <username>deploy</username>  
        <password>pass123</password>
</server>

I have a lot of builds running in Jenkins which use the maven deploy plugin and upload artifacts to the Nexus repo. Since the same user is able to deploy snapshots we can eliminate user roles/permissions issue in Nexus. (I still gave admin role to this user for testing)

Company parent POM

<distributionManagement>
    <repository>
        <id>releases</id>           
        <url>http://myserver/repositories/releases</url>
        <layout>default</layout>
    </repository>

     <snapshotRepository>
            <id>snapshots</id>      
        <url>http://myserver/repositories/snapshots</url>
        <layout>default</layout>
     </snapshotRepository>
</distributionManagement>

Project POM

<scm>
   <connection>scm:svn:http://svnserver/tags/1.2.3</connection>
   <developerConnection>scm:svn:http://svnserver/tags/1.2.3</developerConnection>
</scm>

I have confirmed the /target/checkout/ in the Jenkins workspace contains the latest POM. Also added <distributionManagement> inside the project POM



Now when I run maven release plugin from within Jenkins using mvn release:perform I am still getting this:

Deployment failed: repository element was not specified in the POM inside 
distributionManagement element or in -DaltDeploymentRepository=id::layout
::url parameter


  1. release:prepare shows no errors
  2. The SVN tag gets created as expected
  3. Then during deploy, it fails with the above error
  4. Like I mentioned, snapshot deployment happens frequently and without error, so settings.xml, distributionManagement and Nexus permissions all seem to be in order.
  5. I am able to access http://myserver/repositories/releases manually
  6. I have checked with mvn help:effective-pom and mvn help:effective-settings and things seem to be in order

Any ideas ?

1
Can you try to do a mvn deploy with a release version and a snapshot version. If you get the same results (fails only for a release version) this will pinpoint the error to connection/permissions/etc and not to the release plugin.Sean Connolly
Also, can you sudo into your Jenkins box as the user it runs as and confirm you have the same problem (just trying to eliminiate factors from the table). Also also, can you confirm the settings.xml file you modified is actually being used, here's a question regarding this.Sean Connolly
@SeanConnolly .. thanks 1.nice one about [DEBUG] Reading global.. , I checked and its the correct settings. 2. Can't sudo - dont have access to the box 3. Mvn deploy I am going to try later. 4. I just tried to run the same everything for another maven project and guess what.. it works. So problem is narrowed down to a single multi-module project , which most likely means an error with the one of the POMs.Pulak Agrawal
@SeanConnolly .. it came down to a silly mistake. A user had messed up a child POM and Maven as usual was not kind enough to give the correct error in logs. Meaning the child POM was not reaching the company parent, and so the error. Maven did not say which POM was the problem so I assumed the project ,parent which was alright and set me off on the wrong directions. Sorry, if I wasted your timePulak Agrawal
Glad you got it resolved, cheers.Sean Connolly

1 Answers

0
votes

The error message is very explicit. There is NO distributionManagement in your POM. So you potentially are no inherting from the parent pom.

Run

mvn help:effective-pom 

in the project you are trying to deploy and check. Or alternatively look at the effective POM in your IDE (Eclipse or whatever).

Then figure out the correct parent pom to use or potentially insert the distribtionManagement segment as desired.