AJJ
AJJ

Reputation: 3628

Maven release from Jenkins

I have the following modules in my project,

module - 1
module - 2 
module - 3
module - 4

In the Jenkins maven release, I have to release only the module - 1 and module - 2.

For this I have created the profile in root pom which includes the module -1 and module -2.

<profile>
    <id>jenkins-release</id>
    <modules>
        <module>module - 1</module>
        <module>module - 2</module>
    </modules>
</profile>

How can I make this profile to be executed during Jenkins maven release?

specifying the profile (-P jenkins-release release:prepare release:perform) under "release goals and options" in Jenkins does not work.

In local it works with:

mvn -P jenkins-release release:perform

enter image description here

Upvotes: 2

Views: 1739

Answers (1)

Daniel
Daniel

Reputation: 4221

Your local invocation is not the same. You only specified the goal release:prepare whereas in Jenkins it's release:prepare release:perform.

There are multiple invocations taking place, and therefore you need to use

-Darguments=-Pjenkins-release

You'll notice that I omitted the space between -P and jenkins-releasein order to avoid putting the whole thing between quotes, but I'll leave that to you.

Another option would be to use the releaseProfile setting for the release plugin.

Please see Profile activation on both release:prepare and release:perform for more details.

It's a bit verbose but you should be activating the profile both with -P (for release:prepare) and with -Darguments=... (for release:perform). Also, make sure you use the latest version of maven-release-plugin, as this was buggy a while back.

Like this: mvn -Darguments=-Pjenkins-release -Pjenkins-release release:prepare release:perform

Another approach is to have the profile activate on a custom system property (e.g. -DdoMyRelease=true) or an environment variable that you set through Jenkins.

Have you explored the <releaseProfiles> option? Put it in the root POM if it is from there you are doing your releases.

Upvotes: 2

Related Questions