0

I have a couple of "Invoke top-level Maven targets" build steps in a project being build by Jenkins.

In the "Properties" field you can specify an arbitray amount of maven build parameters like

skipTests=true evaluating to -DskipTests=true

However I want to pass a build parameter that must not be preceded by -D and also does not require an equals sign. Like -Psomething.

Is there any way to do this using the "Invoke top-level Maven targets" or do I need to trigger the mvn build manually via "Execute shell"?

Thanks!

Paxi1337
  • 85
  • 8

1 Answers1

0

A workaround to passing properties is to set environment variables and read them. See this SO post.

Another workaround is by using a profile. Basically in following example you will have to set environment variable RUNTESTS to true to activate your profile and you can do the intended tasks inside this profile (e.g. running junits conditionally.):

<profile>
            <id>runtests</id>
            <activation>
                <property>
                    <name>env.RUNTESTS</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <finalName>re</finalName>
                <plugins>
                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>3.0.0-M1</version>
                        <configuration>
                            <executions>
                                <execution>
                                    <id>default-test</id>
                                    <phase>test</phase>
                                    <goals>
                                        <goal>test</goal>
                                    </goals>
                                </execution>
                            </executions>
                            <forkCount>1</forkCount>
                            <reuseForks>false</reuseForks>
                            <testFailureIgnore>false</testFailureIgnore>
                        </configuration>
                    </plugin>

                </plugins>
            </build>
        </profile>
tryingToLearn
  • 10,691
  • 12
  • 80
  • 114