I want to deploy a 3rd party set of libraries to nexus after building them from the source using maven.
I thought I'd be able to simply use mvn deploy
but I get the following message:
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ dcm4che-parent ---
Uploading: scp://www.dcm4che.org:443/home/maven2/org/dcm4che/dcm4che-parent/3.3.7/dcm4che-parent-3.3.7.pom
The authenticity of host 'www.dcm4che.org' can't be established.
RSA key fingerprint is 41:7f:10:be:8d:15:30:f1:91:59:95:c7:5d:63:f7:31.
Are you sure you want to continue connecting? (yes/no): yes
Password: :
This looks to me like it's trying to deploy to the www.dcm4che.org and not my nexus repo.
Can I not use mvn deploy
in this way?
I can deploy my own libs to nexus this way without any problems.
What am I doing wrong?
UPDATE
After following the advice in this answer I executed the following command:
mvn deploy -DaltDeploymentRepository=nexus::default::http://192.168.50.200:8081/nexus/content/repositories/thirdparty
and I get the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project dcm4che-parent: Failed to deploy artifacts: Could not transfer artifact org.dcm4che:dcm4che-parent:pom:3.3.7 from/to nexus (http://192.168.50.200:8081/nexus/content/repositories/thirdparty): Failed to transfer file: http://192.168.50.200:8081/nexus/content/repositories/thirdparty/org/dcm4che/dcm4che-parent/3.3.7/dcm4che-parent-3.3.7.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
I have added an entry in my settings.xml
as follows:
<servers>
<server>
<id>thirdparty</id>
<username>deployment</username>
<password>password</password>
<configuration></configuration>
</server>
</servers>
2nd UPDATE
I have tried the following command line variations but still can't get it to work. The maven documentation isn't any help.
mvn deploy -DaltDeploymentRepository=thirdparty::default::http://192.168.50.200:8081
produces the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project dcm4che-parent: Failed to deploy artifacts: Could not find artifact org.dcm4che:dcm4che-parent:pom:3.3.7 in thirdparty (http://192.168.50.200:8081) -> [Help 1]
and
mvn deploy -DaltDeploymentRepository=thirdparty::default::http://192.168.50.200:8081/nexus/
produces the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project dcm4che-parent: Failed to deploy artifacts: Could not transfer artifact org.dcm4che:dcm4che-parent:pom:3.3.7 from/to thirdparty (http://192.168.50.200:8081/nexus/): Failed to transfer file: http://192.168.50.200:8081/nexus/org/dcm4che/dcm4che-parent/3.3.7/dcm4che-parent-3.3.7.pom. Return code is: 405, ReasonPhrase: HTTP method PUT is not supported by this URL. -> [Help 1]
and
mvn deploy -DaltDeploymentRepository=nexus::default::http://192.168.50.200:8081/nexus/content/repositories/
produces the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project dcm4che-parent: Failed to deploy artifacts: Could not find artifact org.dcm4che:dcm4che-parent:pom:3.3.7 in nexus (http://192.168.50.200:8081/nexus/content/repositories/) -> [Help 1]
Final UPDATE
For anyone else who might stumble across this, the following command worked. Thanks to A_Di-Matteo for his help.
mvn deploy -DaltDeploymentRepository=thirdparty::default::http://192.168.50.200:8081/nexus/content/repositories/thirdparty
You are probably refering to the dcm4che-parent-3.3.7.pom
artifact, from which:
<distributionManagement>
<repository>
<id>www.dcm4che.org</id>
<name>dcm4che Repository</name>
<url>scp://www.dcm4che.org:443/home/maven2</url>
</repository>
</distributionManagement>
As you can see, its distributionManagement
is refering to the host mentioned in the build error, which is used as the default one.
If you want to deploy to your internal Nexus, you should then use the altDeploymentRepository
option:
Specifies an alternative repository to which the project artifacts should be deployed (other than those specified in
<distributionManagement>
). Format:id::layout::url
.
Its user property is altDeploymentRepository
.
Hence, you can invoke Maven as following:
mvn clean deploy -DaltDeploymentRepository=yourId::layout::URL
Which should match a repository specified in your Maven settings.xml
.
As a general rule, you should not upload to Nexus public artifacts in this way: Nexus can retrieve them for you and be used as a further centralized cache/governance point for other remote repositories.
If you are changing public artifacts and then publishing them in your internal Nexus, then it is really adviced to change their Maven coordinates, at least adding a classifier
specifying something related to your patch/company-name/useful-detail.