YLombardi
YLombardi

Reputation: 1785

Jenkins's maven release plugin - How to set parent project version?

I have a multi-modules project that I want to release with Jenkins. I use Maven 3.3.1, Jenkins 1.651.3 and maven-release-plugin 0.14.0

I create one job for the parent project and one job for each sub project.

Here is the parent configuration :

pom.xml :

<groupId>parent.group.id</groupId>
<artifactId>parent-artifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<scm>
    <url>http://mygitrepo/parent-project.git</url>
    <connection>scm:git:git://mygitrepo/parent-project.git</connection>
    <developerConnection>scm:git:http://mygitrepo/parent-project.git</developerConnection>
</scm>

Jenkins config :

enter image description here

When I perform maven release for the parent project, it works.

Now I do the same thing for a sub project.

pom.xml :

<parent>
    <groupId>parent.group.id</groupId>
    <artifactId>parent-artifact</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</parent>
<scm>
    <url>http://mygitrepo/sub-project.git</url>
    <connection>scm:git:git://mygitrepo/sub-project.git</connection>
    <developerConnection>scm:git:http://mygitrepo/sub-project.git</developerConnection>
</scm>

With the same Jenkins config. I got this error :

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project sub-project: Can't release project due to non released dependencies :
[ERROR] parent.group.id:parent-artifact:pom:1.0.0-SNAPSHOT

The plugin doesn't seem to replace the parent version by the release version.

I read in the maven release plugin's documentation that I can use "-Dproject.dev" and "-Dproject.rel" to specify the parent version to use.

So I tried this :

None of this solve the problem.

How can I configure Jenkins plugin to set the parent-project version ?

Upvotes: 0

Views: 1065

Answers (1)

Clerenz
Clerenz

Reputation: 851

As an alternative you could use the Versions Maven Plugin to set the parent version in an own build step:

mvn versions:update-parent

or to set a specific version

mvn versions:update-parent "-DparentVersion=[1.2.0]"

Upvotes: 0

Related Questions