Divert to locally stored maven-install-plugin - maven

I tried to upload a Windows build to Nexus with the Maven Commandline:
mvn deploy:deploy-file -Durl=http://unity.apps.company.net/nexus/content/repositories/idesktopbuildimages-releases/ -DrepositoryId=idesktopbuildimages-releases -DgroupId=images.WINDOWS7X64EnterpriseSP0unattendedcapture.sources -DartifactId=install -Dversion=6.4 -Dpackaging=wim -Dfile=install.wim
And got the error:
Downloading:
http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
[WARNING] Failed to retrieve plugin descriptor for
org.apache.maven.plugins:maven-clean-plugin:2.4.1: Plugin
org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its
dependencies could not be resolved: Failed to read artifact descriptor
for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1
This happens because I don't have Internet access (only Intranet access).
So is there the possibility to divert to a locally stored maven-install-plugin file in my Maven Command?
PS: I tried -DpomFile but got the same output.
Solution:
Adding the Proxy settings to my settings.xml

If you don't have internet access, I assume you have a mirror of maven central available on your intranet. If it's the case you must configure your settings.xml to declare the mirror. So add something like that in your settings.xml file:
<mirrors>
<mirror>
<id>central-mirror</id>
<name>Local mirror of central repo</name>
<url>http://unity.apps.company.net/nexus/content/repositories/central</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
EDIT
Other thing to look at : you may need to configure some proxy settings (it seems strange that they aren't already there...)
see this

You have to set up your settings file to access the public group of Nexus as described in the Nexus book and ensure that your Nexus server has access to Central.
The url for the public group should be .../nexus/content/groups/public. This default group has the "Central" repository in it.
If you are using a different group like your "releases" you should ensure that the Central repository (or Maven Central in older Nexus releases) is part of the list of ordered group repositories as visible at http://books.sonatype.com/nexus-book/reference/confignx-sect-managing-groups.html#fig-group-config
Once that is set you can confirm that the Central repository is reachable by checking out the the proxy repository Central itself in the repositories view and confirm that you can access the remote repo by using the "Browse Remote" tab visible in http://books.sonatype.com/nexus-book/reference/confignx-sect-manage-repo.html#fig-repo-config
If this browsing does not work you Nexus server is most likely blocked by an internal proxy server. If that is the case you have to configure it in Administration - Server - Default HTTP Proxy Settings.

Related

Resolve maven dependencies from JFrog artifactory by configuration in pom.xml

I need to point Maven to JFrog artifactory ONLY to resolve dependencies and not to deploy. For this I'm not allowed to use settings.xml.
I found artifactory-maven-plugin]1 but it show only how to deploy. The main issue that I need to set username/password to access JFrog and also setup Virtual Repos to resolve artifacts and plugins.
And thoughts how to this without settings.xml via pom.xml? Creds I can add to env variables.
You can add a <repositories> section to your POM. It will not override your <distributionManagement> (for deployment). Whether it will actually work depends on the mirror settings in the settings.xml.
Actually, I find it strange that you do not want to change the settings.xml. If you are not responsible for the settings.xml, you can talk to the relevant manager. You could also ask if the relevant repository is added to the company repository as proxy (if you have such a thing).

Jenkins - deploy artifacts to Maven repository

I have a basic Springboot Maven project and I want to be able to deploy it and make API call as it works in local.
I have a remote linux machine with Jenkins on it, and I am able to make a build of my application correctly. Now I want to deploy this build in the same linux machine, in a certain folder /deploy.
Right now I have added a Post Build Action on Jenkins to Deploy artifacts to Maven repository having the following parameters:
and right now I did not make any changes to my pom.xml or my maven settings.xml.
The error that I get is the following:
[INFO] Deployment in http://localhost:8080/deploy (id=test2,uniqueVersion=true)
Deploying the main artifact reag.login-0.0.1-SNAPSHOT.jar
Downloading: http://localhost:8080/deploy/reag/login/reag.login/0.0.1-SNAPSHOT/maven-metadata.xml
ERROR: Failed to retrieve remote metadata reag.login:reag.login:0.0.1-SNAPSHOT/maven-metadata.xml: Could not transfer metadata reag.login:reag.login:0.0.1-SNAPSHOT/maven-metadata.xml from/to deploymentRepo (http://localhost:8080/deploy): Access denied to: http://localhost:8080/deploy/reag/login/reag.login/0.0.1-SNAPSHOT/maven-metadata.xml , ReasonPhrase:Forbidden.
org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to retrieve remote metadata reag.login:reag.login:0.0.1-SNAPSHOT/maven-metadata.xml: Could not transfer metadata reag.login:reag.login:0.0.1-SNAPSHOT/maven-metadata.xml from/to deploymentRepo (http://localhost:8080/deploy): Access denied to: http://localhost:8080/deploy/reag/login/reag.login/0.0.1-SNAPSHOT/maven-metadata.xml , ReasonPhrase:Forbidden.
The machine where I'm working is protected by username and password, I tried to put them in the settings.xml file but nothing changes. Does anyone know which are the steps to make this process work?
Thanks in advance.
Local artifact deployment is done by mvn clean install.
The install goal copies your artifact into your local maven repository (Default [USER_HOME]/.m2/repository).
If you want to deploy your artifact to another service, like a Nexus Maven Repository, then you need to deploy and also provide the credentials for that machine in your settings.xml, or even better setup a private/public key authentication for the machines.
I think Jenkins is trying to do the remote deploy, which is only working if you run a Maven Repository on your machine (like the Nexus)
"deploy" in Maven parlance means "upload the built artifacts and their metadata (such as pom files) to a repository manager.
It does not mean "copy the artifact to any location that you want".
Therefore as #funfried mentioned, you need to actually have a repository manager running.
If that is the case then the following is how you set up the maven configuration.
Maven links credentials to servers via the id element.
Your settings.xml file would have your credentials setup something like:
<servers>
<server>
<id>newhope-nexus</id>
<username>steve</username>
<password>{1T7Jmp/PBoQH4cvFjZDTaDe/F/Z+D9rJ925rf+3H1LY=}</password>
</server>
</servers>
And then your project model (project pom or parent pom) should define it's distributionManagement:
<distributionManagement>
<repository>
<id>newhope-nexus</id>
<url>http://newhope:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>newhope-nexus</id>
<url>http://newhope:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
Note that the ids all match.
The mvn deploy from Jenkins should then work correctly.

How to use Sonatype Nexus Repository Groups with Github raw repositories?

How can I tell Nexus to download the artifacts from a raw github maven repository when the Proxy Repository in Nexus is in a Repository Group?
Background: In our parent-pom we use a catch all mirror, so we don't have to configure each and every repository to the poms. This works flawless and is also common practice - example:
<mirrors>
<mirror>
<id>provided</id>
<url>http://nexus.host/content/groups/provided</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
But when using a raw github repository this dosn't works. How can I configure Nexus to do this?
Note: I already read "How to add Github raw repositories to Sonatype Nexus as Proxy repository?", but this doesn't tells you how it would run with Repository Groups.
Update: In a manual post step I created the nexus index files with the nexus-indexer-3.0.4-cli.jar, and commited/pushed them to github. Now nexus shows me in the "Browse Index" tab the files in the Proxy Repository, but the problem remains. Clients can not download the artifacts from Nexus.
After creating the proxy repository, you have to add it to the group through which you are accessing Nexus in your build tool. In your case it seems that group uses the id "provided" as visible from the url in the mirror.
See more about adding to repository groups in the Nexus book here and here

Maven Checks the local repository but downloads from central. Why?

We have a local artifactory repository setup for caching. It is configured in our projects, but when I'm looking at stdout of the build process I see rows like this
Downloading: http://ourserver/artifactory/our-repo/javax/transaction/jta/1.1/jta-1.1-sources.jar
Downloading: http://repo1.maven.org/maven2/javax/transaction/jta/1.1/jta-1.1-sources.jar
Downloaded: http://repo1.maven.org/maven2/javax/transaction/jta/1.1/jta-1.1-sources.jar (25 KB at 54.5 KB/sec)
So it looks like it is trying to download the jar from the local repository AND from Maven Central and then actually uses Maven Central).
If I copy the url of the local repository in my browser I get the jar without a problem.
If I check with the admin application of artifactory I can see the artefact.
Can anybody explain why Maven Central is used at all?
UPDATE: What was going on and what I did:
orien's answer explaines why Maven Central was accessed at all.
mliebelt comments hinted me towards my solution: Looks like our local repository was to slow to answer when it had to download the artifact first. I configured the cache to eagerly download jars and sources when a pom gets requested. This should reduce the number of artifacts downloaded from elsewhere.
Maven can be configured with multiple repositories. Adding a repository, as you have in your project, does not invalidate any repositories you have already configured. By default everyone gets the repository at Maven Central. Maven is then free to download an artifact from any repository it has available.
Sounds like what you really want to do is set up a mirror. You can configure a mirror in your settings.xml file:
<mirrors>
<mirror>
<id>our-server-repo</id>
<name>our local repository</name>
<url>http://ourserver/artifactory/our-repo</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
Note that we've used a wildcard (*) in the mirrorOf element. This specifies that all repositories will be accessed via the specified URL. With this configuration Maven will only access your local Artifactory repository.

Why does Nexus repository doesn't download the required artifacts when using a group repository?

I use Nexus repository manager and configured the default .../nexus/content/groups/public/ repository and added maven central, codehaus snapshot and an internal respository that I created and have uploaded few artifacts to that.
Then added .../nexus/content/groups/public to mirror in settings.xml. When I do a maven build, maven looks in .../nexus/content/groups/public but does not update org.apache.maven.plugins:maven-site-plugin:pom:2.0-beta-6 and reports that it is not found.
But if I remove the mirror from settings.xml, then it looks in http://repo1.maven.org/maven2/ and it picks up all the artifacts correctly.
I have also changed publish url to true. What do I miss?
If you added the repositories as proxy repositories in Nexus do not forget to add the proxies to the Repository Group which you use as mirror for all Nexus requests (public/snapshot) - assumed you have this kind of configuration.

Resources