Jenkins: Pass multiple MAVEN profiles via user selection

1.2k Views Asked by At

following situation: I want to build a maven project via jenkins and also be able to select multiple maven profiles (to be precise it has to build with two profiles, one of those is a fixed value called 'dev', so basically I want to be able to select the second profile from a list of profiles) before building, so a parameterized build. I add the selectable profile as a option-list and now I'm able to select it from a dropdown, so far, so good.

BUT: It seems the problem is the multiple profile part.

In the maven goal-field I type

clean install -Pdev,$Client

with 'Client' being the parameter for the build which contains the selected value.

But if I start the build, the command line says e.g.

mvn clean install "-Pdev,test"

with the problem being it wrapping the Profiles in apostrophes. If I test it with a single parameter it works as expected:

clean install -P$Client
1

There are 1 best solutions below

4
On

Based on the following explanation, try some of these:

#1    mvn install -P profile1,profile2
#2    mvn install -Pprofile1 -Pprofile2
#3    mvn install -P 'profile1,profile2'

Explanation

According to official documentation

The correct multi profile invocation is :

mvn groupId:artifactId:goal -P profile1,profile2

And some variations are allowed:

mvn install -Pprofile1 -Pprofile2

Ans as always :s an special treatment for windows:

mvn install -P 'profile1,profile2'