Reputation: 13424
I have an Artifactory repo that sits behind basic authentication. How would I configure the settings.xml to allow access?
<mirrors>
<mirror>
<id>artifactory</id>
<mirrorOf>*</mirrorOf>
<url>https://myserver.example.com/artifactory/repo</url>
<name>Artifactory</name>
</mirror>
</mirrors>
<servers>
<!--
This server configuration gives your personal username/password for
artifactory. Note that the server id must match that given in the
mirrors section.
-->
<server>
<id>Artifactory</id>
<username>someArtifactoryUser</username>
<password>someArtifactoryPassword</password>
</server>
So server tag is the user credentials for the artifactory user, but I also need to provide another user/password to get through the basic-auth. Where would I put that?!?
Upvotes: 26
Views: 42984
Reputation: 587
Most of the time this happens due to following reasons
Username
or the API Key
to access the ArtifactoryYou can see what Maven looks for in what directories... Running with -e -X options will show these details
Sometimes the Settings.xml file may be placed inside a different directory, so when you build locally, maven cannot find it inside ~/.m2 or ~/.m2/conf directories. For e.g if the project uses buildkite, it may be inside a directory that buildkite can access during the build process. In that case, just copy the same Settings.xml file into ~/.m2.
To find the aritifactory, logon to the url using your email/password and go to profile and locate the username and the API Key like in the pic.
Then check the repository is correct in Settings.xml
Upvotes: 0
Reputation: 1152
Tip to solve the problem with the clear text password:
Upvotes: 5
Reputation: 73655
I was able to use the following configuration to enable HTTP basic authentication - by writing the necessary HTTP headers manually. In my situation I used it to access the build artifacts on my Go server as a poor man's staging repository.
<server>
<id>go</id>
<configuration>
<httpHeaders>
<property>
<name>Authorization</name>
<!-- Base64-encoded "guest:guest" -->
<value>Basic Z3Vlc3Q6Z3Vlc3Q=</value>
</property>
</httpHeaders>
</configuration>
</server>
Upvotes: 9
Reputation: 84078
The username and password go in the server settings as you have them. I think your problem is that you've specified the server by its name (Artifactory), rather than its id (artifactory).
I'd recommend you put the server settings in your user settings rather than the global settings. You can also encrypt the password in Maven 2.1.0+, see the mini guide for details.
Update: What version of Artifactory are you using? There is a discussion and corresponding issue that basic-auth fails. This has apparently been fixed in 2.0.7 and 2.1.0.
From the discussion, it seems that a workaround is to pass the properties via the command line, e.g.
-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080 -Dproxy.username=... -Dhttp.password=...
Update: To let your Maven installation connect through a firewall, you'll need to configure the proxy section of the settings.xml, see this question for some pointers on doing that.
Update2: There are additional properties you can set in the server settings, see this blog for some background. I've not had an opportunity to test this, but from the blog and related http wagon javadoc, it appears you can set authenticationInfo on the server settings, something like this:
<server>
<id>Artifactory</id>
<username>someArtifactoryUser</username>
<password>someArtifactoryPassword</password>
<configuration>
<authenticationInfo>
<userName>auth-user</userName>
<password>auth-pass</password>
</authenticationInfo>
</configuration>
</server>
Upvotes: 17