I'm trying to publish the result of a build jenkins/maven to a Nexus repository.
The build is a war SNAPSHOT, here is the beginning of the POM :
<http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.elis</groupIenter code hered>
<artifactId>accueil_ce</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>accueil_ce</name>
I use clean install maven goals for the build.
I've installed and configure the Nexus Repository Manager Publisher plugin for jenkins so it can publish to my nexus Repo in a post build step.
The problem is :
if I configure the repo as 'snapshot' and 'allow redeploy' in Nexus, it doesnt appear in the list of repos available in Jenkins, when configuring the after build step 'Nexus Repository Manager Publisher' of the job.
if I configure the repos as 'release' and 'allow redeploy' in Nexus, then I got the following error when running the jenkins job :
java.io.IOException:com.sonatype.nexus.api.exception.RepositoryManagerException: Unable to upload component: Bad Request The version 0.0.1-SNAPSHOT does not match the repository policy!
I don't understand, there is no way to publish SNAPSHOTs to nexus from jenkins builds with this plugin ??
You need to add distribution management to you pom to control snapshot and release repos.
See https://maven.apache.org/pom.html#Distribution_Management and How to configure maven project to deploy both snapshot and releases to Nexus?
Related
I am trying to promote artifact repository from Snapshot to Release in Nexus using Single artifact uploader in Jenkins . But this is not working for me.
Getting error like :
Could not resolve artifact: Could not find artifact
Snapshots.net.iin:snapshots:jar:0.0.1-SNAPSHOT in stagingrepo.
And I check from configuring the staging suite and got to know that Staging is part of the Nexus Repository Manager Pro.
I am using Nexus version - Nexus Repository Manager OSS 2.14.8-01.
I wanted to promote these snapshot artifacts to Release .So what's the best way to take this forward?
I would like to configure a nexus repository to only manage jars that I install. Right now it also retrieves jars from maven central and stores them in the repository. I don't want that to happen.
Can anyone point me in the right direction how this can be achieved?
When you say to store the "jars that are installed" , if you are referring to the artifacts being created by your project, you can have a hosted maven repository snapshot/release and use maven deploy plugin to upload it on to your nexus repository.
You can either create a profile in your pom and activate in your install it on mvn install phase to upload the artifacts to your nexus repository.
I have internal nexus repository. I want to install plugins from internal repository, having the dependencies which I want to download from the central maven repository. I am new to maven and really struggling to do the required configuration.
Once you deployed your own plugins into a nexus repository (say "releases") add that repository into the Nexus Group that contains both maven central and your releases repository. Usually developers will only use one url (mirror configured in settings.xml) from nexus and deploy artifacts into a specific repository.
In addition you need to make sure to add the maven group id of your plugins into settings.xml in the pluginGroups section: https://maven.apache.org/settings.html#Plugin_Groups
That should already work.
I have added a repository to download artifacts and I have seen maven using that repository to download artifacts, but only for particular artifacts of that repository maven tries to download from mvn central repository. When I chek that artifact on added repository it's available. What could be the issue ? In which situations maven tries to download from central repository ?
Specific issues is highlighted in ,
Magnolia Demo project mvn build failed due to not able to fetch magnolia-setproperty-maven-plugin
All the Maven dependencies are first downloaded from your local repository, then if they are not found, Maven will try in any remote repository that you define in your POM file or the settings.xml and for last it will try to download from Maven Central.
I have a problem currently when i run the command mvn install, the artifact is installed in my local repository (i.e. in %HOME/.m2 folder) but not in the Nexus repository.
I know with Nexus i can add an artifact manually using the GUI but is there a way to do install the artifact as part of the mvn command?
What you're seeing is normal behavior in the standard maven lifecycle. The install phase is only supposed to install the artifact locally. You need to run deploy, which comes after install. That's when maven uploads artifacts to a remote repository. The remote repo for deployment is configured in the distribution management section of the pom.