26
votes

I've set up a build on Jenkins for a Maven project, and I would like to build it without running any of the tests. I've tried entering "clean install -DskipTests" in the goals field, like this:

enter image description here

But it doesn't work. What am I doing incorrectly?

Note: I want to skip the tests without touching the pom. I have a separate build that DOES run the tests.

4
the maven goals you are specifying are just fine... just don't specify the test goal and you should be golden.ddavison
@sircapsalot I'm confused... how am I specifying the test goal in the above example? Or are you saying I'm specifying it somewhere else?James Dunn
I'm saying, as long as you dont put the test goal, it shouldn't run the test. If you just specify clean install it's running the tests? if so, could you post the pom?ddavison
@sircapsalot: Nope, if you run install, it will also run all lifecycles prior to install - including test.Behe
I solved it. I actually needed to enter clean install -DskipTests=true. I had omitted the =true.James Dunn

4 Answers

57
votes

The problem is that I omitted =true. I was able to build without running tests by entering:

clean install -DskipTests=true
11
votes

Just to extend the answer, maven has 2 options for skipping tests:

-DskipTests=true — The one that was mentioned. With this parameter, maven ignores tests completely.

-Dmaven.test.skip=true — With this option maven compiles the tests but doesn't launch them.

So you may want to use the second option instead as fast code compile validation. E.G.: if you develop some library or module that will be used by some one else you must be sure that you don't brake contract with the client. Tests compilation can help you with this.

Use either of these parameters depending on your needs.

3
votes

use "Goals and options" value is "clean install -DskipTests=true".

it works like a Charm. I saved hours of time using this Option. :-)

2
votes

I use option "-DskipTests=true" in "Invoke top-level Maven target" -> "JVM Options" and it works fine.