I've got a password protected jenkins server with the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Maven+Repository+Server" rel="nofollow">Jenkins Maven Repository Server</a> plugin. My problem is, as it is password protected, i can't access the /plugin/repository/everything/ repo from within maven (
Could not transfer metadata <metadata> from/to <repo-name> (http://ci.mydomain.com/plugin/repository/everything/): Access denied to: <repo>/<identifier> , ReasonPhrase:Forbidden.)
What i tried:<br />
- <a href="https://stackoverflow.com/a/27025081" rel="nofollow">Putting the server credentials in the .m2/settings.xml</a><br />
- Basic auth:
- without any auth
any help would be appreciated.
<settings> <servers> <server> <id>test-ci</id> <username>jenkins</username> <password>password</password> </server> </servers> </settings>
and my pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project> <groupId>com.mygroup</groupId> <artifactId>Artifact</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <repositories> <repository> <id>test-ci</id> <url>http://ci.mydomain.com/plugin/repository/everything/</url> </repository> </repositories> <dependencies> <dependency> <groupId>com.mygroup</groupId> <artifactId>ProjectOnCi</artifactId> <version>1.0-SNAPSHOT</version> <scope>provided</scope> </dependency> </dependencies> </project>Answer1:
Just struggled a few hours with this problem today and finally found an answer.
First of all, to use HTTP basic authentication, you need to supply user and <strong>API Token</strong> as password. You can find this token at "Manage Jenkins" -> "Manage Users" -> "Edit User" (Settings icon next to user) -> "Show API Token".
Secondly, Jenkins is using <strong>preemptive authentication</strong>, which means that there is no HTTP authentication negotiation but you need to immediately send the credentials in the first request. You can read about it here: <a href="https://wiki.jenkins.io/display/JENKINS/Authenticating+scripted+clients" rel="nofollow">https://wiki.jenkins.io/display/JENKINS/Authenticating+scripted+clients</a>
To configure your Maven repository accordingly, make sure to use the following server configuration:
<server> <id>test-ci</id> <username>YOUR_USER</username> <password>YOUR_API_TOKEN</password> <configuration> <httpConfiguration> <all> <usePreemptive>true</usePreemptive> </all> </httpConfiguration> </configuration> </server>
This should work. I hope I could help you :)Answer2:
You should note that <a href="https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Maven+Repository+Server" rel="nofollow">Jenkins Maven Repository Server</a> will not perform as Maven Repository, so if this is what you need (a Maven repo) - this Jenkins plugin will not help.
I suggest reading about <a href="https://maven.apache.org/guides/introduction/introduction-to-repositories.html" rel="nofollow">Maven Repos</a>; from what you write I think that an internal repository (e.g. <a href="http://www.sonatype.org/nexus/" rel="nofollow">Nexus</a>, <a href="https://www.jfrog.com/artifactory/" rel="nofollow">Artifactory</a>) might be good. Maven by default downloads JARs from Maven Central, so you do not (and should not) have to download all sources and build them.