Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publishing SNAPSHOT to nexus from jenkins/maven build

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 ??

like image 708
oscarito75020 Avatar asked Apr 21 '17 09:04

oscarito75020


1 Answers

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?

like image 120
Essex Boy Avatar answered Oct 31 '22 05:10

Essex Boy