1

We need to deploy same artifact into two (or more) nexus repositories. For this purpose we are using two separate profiles with different distributionManagement sections like this:

<profile>
    <id>deploy-nexus1</id>
    <distributionManagement>
        <repository>
            <id>releases1</id>           
            <url>http://repositories/releases1</url>
        </repository>
        <snapshotRepository>
            <id>snapshots1</id>      
            <url>http://repositories/snapshots1</url>
        </snapshotRepository>
    </distributionManagement>
</profile>
<profile>
    <id>deploy-nexus2</id>
    <distributionManagement>
        <repository>
            <id>releases2</id>           
            <url>http://repositories/releases2</url>
        </repository>
        <snapshotRepository>
            <id>snapshots2</id>      
            <url>http://repositories/snapshots2</url>
        </snapshotRepository>
    </distributionManagement>
</profile>

Desired result: to have same artifact:1.0.0 in releases1 and releases2. But after running command:

mvn clean release:prepare -U
mvn clean release:perform -U -P deploy-nexus1
mvn clean release:perform -U -P deploy-nexus2

Deploy to releases1 repository was successful, but deploy to releases2 returned:

No SCM URL was provide to perform the release from

According to plugin documentation, before every release:perform we need to run release:prepare or provide custom url to tag in repo.

How could we perform two nexus deployments of one artifact version? Is it possible to add additional deploy step within release:perform command?

Thanks in advance.

kaitoy
  • 1,545
  • 9
  • 16
  • I am sorry to doubt your approach, but it seems strange to me: Why deploy twice? If you want to make your artifact available in different nexus instances, you can use a proxy repository in nexus. Could you give us a little background on why you want two deployments? – J Fabian Meier Nov 18 '16 at 14:49
  • Sure, `nexus1` is our internal nexus and we use it as usual nexus. Other maven modules can download their dependencies from `nexus1` if needed. But `nexus2` is external repository, we push there only packaged application that can we used for immediate deployment. Corporate application `XXX Deploy` uses `nexus2`, it downloads artifact from `nexus2`, un-pack it on a target host and start up an application. Therefore, we need to upload artifact into `nexus1`, because it is main nexus for us, and upload to `nexus2`, because this needed for continious delivery process. – Viktor Khvostov Nov 19 '16 at 17:52
  • I would think about the following approach: Proxy your nexus2 in nexus1. Then all artifacts of nexus2 are also available in nexus1 without any further steps. – J Fabian Meier Nov 21 '16 at 07:53
  • We can not do this. As I said before, nexus2 is external repository, therefore we can not configure it overall. Even nexus1 can not be configured by us, because many other teams use nexus1 for their needs. So, configuring nexus is not the option for us. – Viktor Khvostov Dec 02 '16 at 10:11
  • If you have absolutely no access to the nexus configuration (it's a pity but it sometimes happens in large organisations), then I would think about running a copy job that downloads artifacts from one repository (by using REST or Aether) und uploads them to the other. This is safer than a double deployment – J Fabian Meier Dec 02 '16 at 10:41

1 Answers1

0

From documentation you refer :

We can see at the end :

After the release is complete, the release.properties and other release files will be removed from the checkout.

And before we can read :

mvn release:perform

This relies on release.properties being present from a previous release preparation. If this is not the case, you need to give the goal the URL and an optional tag to perform the release from. For example:

mvn org.apache.maven.plugins:maven-release-plugin:2.5.3:perform -DconnectionUrl=scm:svn:https://svn.mycompany.com/repos/path/to/myproject/tags/myproject-1.2.3

And your error is No SCM URL was provide to perform the release from, So I suppose you should precise the tag of released component since release.properties doesn't exist any longer after the first release:perform. You could do something like that :

mvn clean release:perform -U -P deploy-nexus2 -DconnectionUrl=scm:svn:urlOfTaggedProject

Another solution to avoid entering at the end the tag url would be to do a copy of release.properties before the first release:perform somewhere in the current folder. For example by copying and renaming it differently and after the first perform you could rename it release.properties in order that it is reused during the second release:perform. With a very simple script,it could be automatisable.
I don't know if it may work as I never had this requirement. Maybe, you will have other side-effects, these are just guessworks.
but don't hesitate to do a feedback :)

davidxxx
  • 125,838
  • 23
  • 214
  • 215
  • Thanks for your answer. I have bash script for automation, therefore I want to avoid using tag's url, script does not know about particular release version. Approach with copying of `relese.properties` looks like workaround. Applicable, but I wonder to find solution that `maven-release-plugin` can offer instead. – Viktor Khvostov Nov 16 '16 at 12:52
  • You are welcome. I understand but in the second part, I explain you could reuse the original release.properties generated during release:prepare goal. So with scripting, you could do it. – davidxxx Nov 16 '16 at 12:55