Maven. Repository authentication - maven

I tried setup deploy to local repository:
-- settings.xml --
<server>
<id>myrepo</id>
<username>deployer</username>
<password>123456</password>
</server>
-- pom.xml ---
<repositories>
<repository>
<id>myrepo</id>
<url>http://myserver.com/artifactory/libs-release-local</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
when I execute "mvn deploy" I got error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.4:
deploy (default-deploy) on project xxx: Failed to deploy artifacts: Co
uld not transfer artifact xxx:xxx:war:0.1-20130527.121430-3 from/to myserver.com
(http://myserver.com:8083/artifactory/libs-snapshot-local): Failed to transfer file:
http://myserver.com:8083/artifactory/libs-snapshot-local/xxx/0.1-SNAPSHOT
/xxx-0.1-20130527.121430-3.war. Return code is: 401
Artifactory log:
2013-05-27 16:14:38,158 [DENIED DEPLOY] libs-snapshot-local:xxx/0.1-SNAPSHOT
/xxx-0.1-20130527.121430-3.pom for anonymous/192.168.6.36.
If I change server/repository id to "myserver.com" - deploy WORK!
But it does not suit me because that did not work plugin changelog with svn at myserver.com
I tried to add tags "profile" and "mirror" to server.xml and "distributionManagement" to pom.xml - getting the same error
server/repository id must be named ONLY as my server?
UPDATE1:
I remove tag 'repositories' from pom.xml and added tag 'distributionManagment':
--- pom.xml ---
<distributionManagement>
<repository>
<id>myrepo</id>
<name>myrepo</name>
<url>http://myserver.com/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>myrepo</id>
<name>myrepo</name>
<url>http://myserver.com/artifactory/libs-snapshots-local</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
(server.xml has not changed) - getting the same error "Failed to deploy..."
UPDATE2:
Try...
--- server.xml ---
<profiles>
<profile>
<id>artifactory</id>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://myserver.com/artifactory/libs-release-local</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://myserver.com/artifactory/libs-snapshot-local</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
<server>
<id>snapshots</id>
<username>deployer</username>
<password>123456</password>
</server>
<server>
<id>central</id>
<username>deployer</username>
<password>123456</password>
</server>
--- pom.xml ---
<distributionManagement>
<repository>
<id>central</id>
<name>Internal Releases</name>
<url>http://myserver.com/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name>
<url>http://myserver.com/artifactory/libs-snapshots-local</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
execute 'mvn deploy' - again error :(
Failed to deploy artifacts: Could not transfer artifact xxx:xxx:war:0.1-20130528.050526-1 from/to snapshots (http://myserver.com/artifactory/libs-snapshots-local)

The 'repositories' tag is used for resolution, not for deployment. I'd speculate that the id of the repository under 'distributionManagment' tag is 'myserver.com', that's why it matches the server declaration in settings.xml

You settings.xml is missing the <servers> </servers> tags around your two <server> nodes. - https://maven.apache.org/settings.html#Servers
Also, I would avoid using generic id's like 'snapshots' and 'central'. Understandable if they are there for the purpose of SO.
The last update to this question didn't include the specific error code, but in the original error it was a 401 (Unauthorized) which leads me to believe that it's not able to find your servers authentication information due to invalid settings.xml

Related

Artifactory OSS throwing 405 Exception when running maven release:perform

artifactory-oss-6.7.2 is throwing a 405 status code exception when running maven release:perform
Created a settings.xml from artifactory "generate settings.xml" on repo. All repos are virtual repos. Added distributionManagement to my project pom file to use the ids for snapshots and releases from settings.xml.
settings.xml:
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://localhost:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://localhost:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
myproject/pom.xml:
<distributionManagement>
<repository>
<id>central</id>
<name>Artifactory Release Repo</name>
<url>http://localhost:8081/artifactory/libs-release</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Artifactory Snapshot Repo</name>
<url>http://localhost:8081/artifactory/libs-snapshot</url>
</snapshotRepository>
</distributionManagement>
run mvn release:perform output:
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project model: Failed to deploy artifacts: Could not transfer artifact com.test:model:jar:0.1.0 from/to central (http://localhost:8081/artifactory/libs-release): Failed to transfer file http://localhost:8081/artifactory/libs-release/com/srcrea/model/0.1.0/model-0.1.0.jar with status code 405 -> [Help 1]
So I followed something I found here -> http://forums.jfrog.org/Error-Code-405-with-mvn-deploy-td7174367.html
And updated DistributionManagement of the pom.xml
<distributionManagement>
<repository>
<id>central</id>
<name>Artifactory Release Repo</name>
<url>http://localhost:8081/artifactory/88888</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Artifactory Snapshot Repo</name>
<url>http://localhost:8081/artifactory/88888</url>
</snapshotRepository>
</distributionManagement>
Re-Run and now I see it:
But what is not clear is in order to generate settings.xml you need to associate virtual repos to a local repo. Then generate settings off that and use the distributionManagement configuration to point back to the local repo. What is the point of the virtual repo?

Configure jcenter for only downloading artifacts and Artifactory for deploying artifacts

We have Artifactory setup and we use Maven central repo for downloading artifacts, which are then automatically cached in Artifactory. We also upload/deploy our own artifacts in Artifactory.
I now want to replace Maven central repo with jcenter and would like to continue using our Artifactory for uploading/deploying our own artifacts and for also caching the jcenter (and any third-party) artifacts. I can ask all developers to modify their settings.xml file as it will be a one-time activity so that's not a problem.
I saw this link by #helmedeiros which describes making changes in <repositories> and <pluginRepositories> section of settings.xml file. However, those are the sections where i specify URL for our Artifactory server. If i replace my Artifactory URL, then it would mean that i will be able to both fetch and upload artifacts from jcenter which is not what i want.
How can i ensure that all developers are only able to pull (NOT deploy/upload) from jcenter and deploy/upload ONLY to Artifactory?
Here's what we have right now in settings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>${security.getCurrentUsername()}</username>
<password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
<id>central</id>
</server>
<server>
<username>${security.getCurrentUsername()}</username>
<password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>https://inhouse-artifactory/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>https://inhouse-artifactory/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>https://inhouse-artifactory/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>https://inhouse-artifactory/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
I will really appreciate any help in this regard.
I have exactly the same question :)
My solution is to create an Artifactory virtual repository (forgerock-third-party-virtual) to cache most of the public artifacts.
This virtual repository includes a remote repository based on jcenter:
On the virtual repository, there is no default deployment repository:
So with this setting, I hope the developers won't be able to push in this virtual repository.
According to the JFrog documentation, you have select one repository in this drop-down to be able to push into a virtual repository.
Regarding the deployment settings, we also have a parent pom where we specified our own repositories in the <distributionManagement> section.
On my build machines, I've added this profile (in .m2/settings.xml) to cache the artifacts:
<profile>
<id>force-third-party-repo</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>forgerock-third-party</id>
<name>ForgeRock Third Party Repository</name>
<url>http://maven.forgerock.org/repo/forgerock-third-party-virtual</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>forgerock-third-party</id>
<name>ForgeRock Third Party Repository</name>
<url>http://maven.forgerock.org/repo/forgerock-third-party-virtual</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
I have other settings in this file to declare our own Artifactory repositories (for pushing/pulling our own artifacts) + some Maven credentials.
I did some tests with one of our Maven projects and it was working fine.
Once the new .m2/settings.xml will be ready, I'll push a template in an internal Artifactory repository, so the developers will be able to get this template with a curl command.
FYI, this is a POC for the moment. We want to move in production with these settings in a few days.

Jenkins Maven job unable to access plugins for deployment from repositories

I am new to Jenkins. As part of POC i tried to deploy a basic SOA project from command line "mvn pre-integration-test", it was successfully deployed to localhost weblogic server. However, when tried Jenkin's job polling svn code, its failing repeatedly with following error msg:
Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\workspace\testAppSairu
Updating protocol://xxx/svn/testAppSairu/branches/testAppSairu at revision '2015-10-19T18:08:19.290 +0530'
At revision 2
no change for protocol://xxx/svn/testAppSairu/branches/testAppSairu since the previous build
Setting environment Jenkins.Repository = protocol://localhost:8088/repository/dev
Parsing POMs
Setting environment Jenkins.Repository = protocol://localhost:8088/repository/dev
Setting environment Jenkins.Repository = protocol://localhost:8088/repository/dev
ERROR: Failed to parse POMs
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Failure to transfer com.oracle.soa:sar-common:pom:12.1.3-0-0 from protocol://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact com.oracle.soa:sar-common:pom:12.1.3-0-0 from/to central (protocol://repo.maven.apache.org/maven2): Connection to protocol://repo.maven.apache.org refused and 'parent.relativePath' points at no local POM # line 21, column 13
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:364)
Note: I used maven sync plugin to install and push weblogic home into local repository and also Archiva managed repository. While running mvn compile/pre-integration-test i am able to deploy it successfully but failing here since its unable to access plugins.
.m2 settings.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<localRepository>${user.home}/.m2/repository</localRepository>
<interactiveMode>true</interactiveMode>
<offline>false</offline>
<profiles>
<profile>
<id>default</id>
</pluginRepositories>
<pluginRepository>
<id>maven.oracle.com</id>
<url>https://maven.oracle.com</url>
</pluginRepository>
<pluginRepository>
<id>dev</id>
<name>Dev</name>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://localhost:8088/repository/dev</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>maven.oracle.com</id>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>https://maven.oracle.com</url>
<layout>default</layout>
</repository>
<repository>
<id>dev-group</id>
<name>Dev Group</name>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://localhost:8088/repository/dev-group</url>
<layout>default</layout>
</repository>
<repository>
<id>dev</id>
<name>Dev</name>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://localhost:8088/repository/dev</url>
<layout>default</layout>
</repository>
<repository>
<id>snapshots</id>
<name>Archiva Managed Snapshot Repository</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://localhost:8088/repository/snapshots</url>
<layout>default</layout>
</repository>
</repositories>
</profile>
</profiles>
<mirrors>
<mirror>
<id>dev-mirror</id>
<name>All Else</name>
<url>http://localhost:8088/repository/dev-group</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<servers>
<server>
<id>maven.oracle.com</id>
<username>OTN username</username>
<password>OTN password</password>
<configuration>
<basicAuthScope>
<host>ANY</host>
<port>ANY</port>
<realm>OAM 11g</realm>
</basicAuthScope>
<httpConfiguration>
<all>
<params>
<property>
<name>http.protocol.allow-circular-redirects</name>
<value>%b,true</value>
</property>
</params>
</all>
</httpConfiguration>
</configuration>
</server>
<server>
<id>dev</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>dev-group</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<activeProfiles>
<activeProfile>defualt</activeProfile>
</activeProfiles>
</settings>
As suggested in docs.oracle.com/middleware/1213/core/MAVEN.pdf, i have downloaded wagon-http-2.8-shaded.jar and placed underapache-maven-3.3.3\lib\ext folder. Updated repository, server details etc in settings.xml. But still issue is not resolved.
My intention is to deploy a simgle SOA 12c project using Jenkin's maven job part of Continuous Integration flow. Please suggest if i am missing anything here. I am rookie on this so any help will save my day. Thanks!

Maven deploy error

I have maven project with several modules. Need to deploy all modules(jars and one resulting war) into remote Artifactory server.
So in settings.xml I am added config:
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>admin</username>
<password>password</password>
<id>central</id>
</server>
<server>
<username>admin</username>
<password>password</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<id>central</id>
<name>libs-release</name>
<url>http://192.168.1.120:8088/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://192.168.1.120:8088/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://192.168.1.120:8088/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://192.168.1.120:8088/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
Main pom have section:
<distributionManagement>
<repository>
<id>central</id>
<url>http://192.168.1.120:8088/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.1.120:8088/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
And all modules have 1.0-SNAPSHOT version.
But when executing the command: >mvn deploy, the Following error occured:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy
(default-deploy) on project jobic: Failed to deploy artifacts: Could
not transfer artifact *project-name:project-nam*e:pom:0.0.1 from/to central
(http://192.168.1.120:8088/artifactory/libs-release-local): Failed to
transfer file:
http://192.168.1.120:8088/artifactory/libs-release-local/project-name/project-name/0.0.1/project-name-0.0.1.pom.
Return code is: 401 -> [Help 1]
How to deal with it?
UPDATE:
Ok, I got it. The 401 error says: 401 = "Unauthorized" . So I added proper username/password into settings.xml. Seems work now.
Have one last question: it is right, that I am using SNAPSHOT suffix in the version? Is it proper behavior for situation, when I need do deploy all modules onto remote repo? How to deal with situation, when the one module was broken and my coworkers need to use previous version of this module?
It might be because it is written incorrectly.
You can change it hhttp to http and try again.

Maven Nexus private repository access

I have just set up a nexus repository in my local network. This repository exposes access to the Maven central repository, plus three different private hosted repositories: snapshot, release and ext3rdparty. All these repositories are part of the public group in nexus, which I use as a central access point for all repositories:
http://nexus.server/nexus/content/groups/public/
My problem is: Using NetBeans as development envirnment, I can access to all repositories except the ext3rdparty. i.e. i got a compilation error when I try to build projects which are based on libraries stored in the ext3rdparty repo, and NetBeans can't find / navigate any of the artifacts available in this repository.
I suspect this is a settings.xml / pom.xml problem and not a NetBeans one because as I said, I can access to artifacts that I've released in other repositories, but I can't figure-out what's the problem.
Here is the FULL content of my settings.xml to redirect maven to my own repository:
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://nexus.server/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
<servers>
<server>
<id>nexus</id>
<username>user</username>
<password>***</password>
</server>
<server>
<id>releases</id>
<username>user</username>
<password>***</password>
</server>
<server>
<id>snapshots</id>
<username>user</username>
<password>***</password>
</server>
</servers>
And here is the repositories-related part of my parent pom to allow deployment:
<distributionManagement>
<repository>
<id>releases</id>
<name>Releases</name>
<url>http://nexus.server/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Snapshots</name>
<url>http://nexus.server/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
Any idea of what's wrong ?
Thanks in advance!
EDIT:
Half of a day lost: I finally ended up with removing all dependencies from the ext3rdparty repository, uploading them again to the repository, and updating all indexes and now everything works fine...
Don't really know what was the problem here, but at least the pom and the settings were OK. Thanks for your help.
If you have that sort of problem you can right click on the affected repository in the Repositories list and activate a Repair Index or Update Index and then check the status in the System Feeds for System updates.
Did you add your ext3rdparty repo to your public group?

Resources