TeamCity/Maven DONT make modules be 'SKIPPED' - maven

Lets say I've a root project called R. And it has modules A, B, C and D as submodules but each is an application.
Whenever I use teamcity/maven and there is an error it skips other modules whether its a compile/test.
So,
Whenever compiling it shows
R................SUCCESS
A................SUCCESS
B................FAILURE
C................SKIPPED
D................SKIPPED
And I want to see results in both C and D. How can I achieve this using teamcity/maven. Is there any parameter?

If you use mvn --fail-at-end all modules will be gone through but the failure will be shows only at the end of the build.

This option must be used carefully, but can be useful. The build never fails, regardless of the project result. All failures are ignore, the build just continues. On your project:
mvn clean install --fail-never (or just --fn)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Module A .............................................. SUCCESS [2.583s]
[INFO] Module B .............................................. SUCCESS [0.086s]
[INFO] Module C .............................................. FAILED [1.598s]
[INFO] Module D .............................................. SUCCESS [0.051s]
[INFO] Reactor ............................................... SUCCESS [0.921s]
[INFO] ------------------------------------------------------------------------
[INFO] Error for project: Module C (during install)
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.
Please refer to /Users/clement/workspaces/experiments/Project/module-C/target/surefire-reports for the individual test results.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] + Ignoring failures
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Sun May 09 10:43:41 CEST 2010
[INFO] Final Memory: 31M/79M
[INFO] ------------------------------------------------------------------------
Module C failed, D is not skipped, and the global build is successful.
After that in the Teamcity you can add build failure condition for checking the results and failed the build if found any errors

Related

Maven: Full reactor summary after resume a build with mvn goal -rf :module

I'm using maven to manage the build of a large project that it's divided in several modules that are built from the root. So, in this case, maven will use the reactor functionality to build each module in the correct order.Something like this:
root/pom.xml
sp1/pom.xml
sp2/pom.xml
sp3/pom.xml
sp4/pom.xml
I build the project with maven from root directory using the command
mvn clean install
If the build is OK, maven will print the reactor summary:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Root Project ....................................... SUCCESS [ 18.271 s]
[INFO] sp1 ................................................ SUCCESS [ 2.034 s]
[INFO] sp2 ................................................ SUCCESS [ 22.770 s]
[INFO] sp3 ................................................ SUCCESS [03:39 min]
[INFO] sp4 ................................................ SUCCESS [04:39 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 46:34 min
[INFO] Finished at: 2017-10-04T17:08:11+00:00
[INFO] Final Memory: 256M/1599M
[INFO] ------------------------------------------------------------------------
But, What happens if one of build phase of one of the subproject fails?. For example, some tests in the sp2 subproject fail and I fix them and relaunch the build from the sp2 with this command
mvn clean install -rf :sp2
The project is built correctly. Then, maven prints the reactor, but not the full reactor, only from sp2. Something like this:
```
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] sp2 ................................................ SUCCESS [ 22.770 s]
[INFO] sp3 ................................................ SUCCESS [03:39 min]
[INFO] sp4 ................................................ SUCCESS [04:39 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 46:34 min
[INFO] Finished at: 2017-10-04T17:08:11+00:00
[INFO] Final Memory: 256M/1599M
[INFO] ------------------------------------------------------------------------
My question is: Is it possible to obtain the full reactor summary (including the modules that have been built in the previous execution?)
Reactor Build Order is resolved during Reactor Sorting which leads into a deterministic sequence of execution for the list of projects. The command --resume-from (-rf) as used in:
mvn clean install -rf :sp2
resumes reactor build from the specified project, where the order is similar to as was already been decided, it simply traverses the remaining of the projects in the list which is the updated Reactor Build Order and hence the Reactor Summary corresponds to the new build order.

How can I force Maven clean install to only show the summary of build?

The -q option is a bit too quiet for me, only shows debug and errors.
Is there any way I can force Maven to output only the summary?
ie:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] project ........................................... SUCCESS [ 2.437 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:30 min
[INFO] Finished at: 2016-04-15T10:35:15-05:00
[INFO] Final Memory: 221M/1383M
[INFO] ------------------------------------------------------------------------
Something like this will work:
(mvn clean install -l temp.build.log; grep -B 1 -A 500 Reactor\ Summary temp.build.log; rm temp.build.log)

How to compile all maven modules even if tests fail, but fail overall build if any tests fail

Context: I want to compile and test all modules in a multi-module project but if any fail either compilation or tests I want the overall build to fail.
Default configurations either stop on the first failure or skip modules after a test failure
Running:
mvn clean install
stops at the first failing module.
If you add:
mvn clean install -fae //fail at end
then all modules are run, but if tests fail then any dependent modules are skpped:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Module A ............................................. SUCCESS [15.210s]
[INFO] Module B ............................................. SUCCESS [10.923s]
[INFO] Module C ............................................. FAILED [1.731s]
[INFO] Module D ............................................. SUCCESS [3.791s]
[INFO] Module E ............................................. SUCCESS [1.488s]
[INFO] Module F ............................................. SKIPPED (dependency build failed or was skipped)
[INFO] Module G ............................................. SKIPPED (dependency build failed or was skipped)
[INFO] Module H ............................................. SKIPPED (dependency build failed or was skipped)
[INFO] Module I ............................................. SUCCESS [1.690s]
[INFO] -----------------------------------------
Another option to force all modules to compile is:
mvn clean install -fn //fail never
but this results in the build passing when tests fail
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Module A ............................................. SUCCESS [15.210s]
[INFO] Module B ............................................. SUCCESS [10.923s]
[INFO] Module C ............................................. FAILED [1.731s]
[INFO] Module D ............................................. SUCCESS [3.791s]
[INFO] Module E ............................................. SUCCESS [1.488s]
[INFO] Module F ............................................. SUCCESS [9.062s]
[INFO] Module G ............................................. SUCCESS [16.324s]
[INFO] Module H ............................................. SUCCESS [4.032s]
[INFO] Module I ............................................. SUCCESS [1.690s]
[INFO] ------------------------------------------------------------------------
[INFO] Error for project: Module C (during install)
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.
Please refer to C:\MavenBuildDir\ModuleC\surefire-reports for the
individual test results.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] + Ignoring failures
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30 minutes 38 seconds
[INFO] Finished at: Fri May 23 16:42:08 BST 2014
[INFO] Final Memory: 39M/185M
Can anyone advise a set of options to achieve the following:
compile all modules
run tests on all modules
If a module's tests fail but the code compiles dependent modules still get compiled and tested
Responses much appreciated - otherwise we have to run the tests repeatedly on the build server if there are multiple issues - burning a lot of time.
I would suggest to use:
mvn -Dmaven.test.failure.ignore=true --fail-at-end clean install
I would suggest to split it into two mvn calls:
mvn clean compile
mvn -fae install
The first call will fail, if there are compile errors. The second call will reuse the compiled .class-files, since "clean" is omitted. It will fail at the end, if there are test failures. But compilation has already been finished for ALL modules.
Here is a different approach: parse maven output. So either you
pipe it into some grep like command:
mvn clean install -fn | perl -pe 'END { exit $status } $status=1 if /BUILD FAILURE/;'
See https://github.com/backuitist/maven-fae-seriously
configure your CI server to do it:
See https://stackoverflow.com/a/28683700/303737

Maven Dependency Plugin appendOutput Parameter is Failing?

UPDATE: This issue seems to have resolved itself. I could still produce it on a copy of the source code, but it was a temporary copy that I deleted before realizing I would need it to pin this issue down. I'm continuing to track this and see if I can identify a root cause. If not, I will close the issue.
When I run mvn dependency:list -DoutputFile=/path/to/file.txt -DappendOutput=true from the root directory of a multi-module Maven project, the resultant output file only contains the dependencies of the last module declared in the modules section of the root pom.xml file. Is there something different I need to do to get the output of each submodule to append to the output file?
Configuration:
Maven 3.0.3
maven-dependency-plugin 2.6
When I'm using the following command: -
mvn dependency:list -DoutputFile=/path/to/file.txt -DappendOutput=true
The result is invalid and the Maven told me that
[INFO] --- maven-dependency-plugin:2.1:list (default-cli) # ...
Then I change to specify the version
mvn org.apache.maven.plugins:maven-dependency-plugin:2.6:list -DoutputFile=/path/to/file.txt -DappendOutput=true
The result is valid and the Maven told me that
[INFO] --- maven-dependency-plugin:2.6:list (default-cli) # ...
I would suggest you to ensure that the executing is the version 2.6. Anyhow I always use the following command as
mvn dependency:list > /path/to/file.txt
IMHO the result is better and more clear for each module as the following example: -
[INFO] Scanning for projects...
[INFO] -------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] my-parent
[INFO] my-sub1
[INFO] my-sub2
[INFO]
[INFO] -------------------------------------------------------------------
[INFO] Building my-parent
[INFO] -------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:list (default-cli) # my-parent ---
[INFO]
[INFO] The following files have been resolved:
...
[INFO] -------------------------------------------------------------------
[INFO] Building my-sub1
[INFO] -------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:list (default-cli) # my-sub1 ---
[INFO]
[INFO] The following files have been resolved:
...
[INFO] -------------------------------------------------------------------
[INFO] Building my-sub2
[INFO] -------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:list (default-cli) # my-sub2 ---
[INFO]
[INFO] The following files have been resolved:
...
[INFO]
[INFO] -------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] my-parent ........................................ SUCCESS [0.745s]
[INFO] my-sub1 .......................................... SUCCESS [0.675s]
[INFO] my-sub2 .......................................... SUCCESS [0.671s]
[INFO] -------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] -------------------------------------------------------------------
[INFO] Total time: 2.938s
[INFO] Finished at: Fri Mar 01 17:01:39 ICT 2013
[INFO] Final Memory: 17M/218M
[INFO] -------------------------------------------------------------------
I hope this may help.
Regards,
Charlee Ch.

Hudson: Builds of multi-module maven project fail, then immediately succeed again

I have a multi-module project where the top level project serves both as the parent of the individual modules and as the project that declares the modules. Only this top level project is configured in Hudson (including automatic SVN checkout). The simplified layout is as follows:
ProjectRoot\
|
+---kernel\
| |
| +---pom.xml [ArtifactId=MyProject_kernel parent=MyProject]
|
+---model_foo\
| |
| +---pom.xml [ArtifactId=MyProject_model_foo, parent=MyProject]
|
+---pom.xml [ArtifactId=MyProject, parent=none]
Also, model_foo has a dependency on kernel.
Now, Hudson automatically discovers the kernel and model_foo sub projects, and it usually manages to build everything just fine.
However, each time I make a breaking change, such as create a new class in kernel and use it inside model_foo, I get a failing build for model_foo, followed by one that succeeds. The mail notifications are titled
Build failed in Hudson: MyProject » MyProject Model Foo #1545
Hudson build is back to normal : MyProject » MyProject Model Foo #1546
Why is that? I suspect it might have to do with the fact that the MyProject pom.xml is both the multi-module project and the parent of its modules, but before changing that I would like to know whether it's actually going to help.
I use Hudson 2.1.0.
Update
This is the log of a failed build of the web module (equals model_foo in the diagram above). The build for the MyProject root project had the same build number, and succeeded.
I stripped out the actual compiler errors, which are exactly the same as if the newly introduced class was missing.
Started by upstream project "MyProject" build number 1545
Found mavenVersion 2.0.9 from file jar:file:/home/builder/opt/apache-maven-2.0.9/lib/maven-2.0.9-uber.jar!/META-INF/maven/org.apache.maven/maven-core/pom.properties
$ /home/builder/opt/jdk1.5.0_22//bin/java -Xmx1024m -Xms512m -cp /home/builder/var/hudson/plugins/maven-plugin/WEB-INF/lib/maven-agent-2.1.0.jar:/home/builder/opt/apache-maven-2.0.9/boot/classworlds-1.1.jar hudson.maven.agent.Main /home/builder/opt/apache-maven-2.0.9 /home/builder/opt/apache-tomcat-6.0.24/webapps/hudson/WEB-INF/lib/hudson-remoting-2.1.0.jar /home/builder/var/hudson/plugins/maven-plugin/WEB-INF/lib/maven-interceptor-2.1.0.jar 48555
<===[HUDSON REMOTING CAPACITY]===> channel started
Executing Maven: -N -B -f <http://ciserver:8080/hudson/job/MyProject/com.mycompany.myproject$web/ws/pom.xml> clean deploy -Dworkspace.path=/home/builder/var/hudson/jobs/MyProject/workspace/ -Droot.project.name=MyRoot -e
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProject
[INFO] task-segment: [clean, deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory <http://ciserver:8080/hudson/job/MyProject/com.mycompany.myproject$web/ws/target>
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Compiling 945 source files to <http://ciserver:8080/hudson/job/MyProject/com.mycompany.myproject$web/ws/target/classes>
[HUDSON] Archiving <http://ciserver:8080/hudson/job/MyProject/com.mycompany.myproject$web/ws/pom.xml> to /home/builder/var/hudson/jobs/MyProject/modules/com.mycompany.myproject$web/builds/2011-09-27_13-32-33/archive/com.mycompany.myproject/web/1.1-SNAPSHOT/pom.xml
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
{{{compiler failure here}}}
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: Compilation failure
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:579)
{{{stacktrace omitted}}}
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
{{{stacktrace omitted}}}
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 7 seconds
[INFO] Finished at: Tue Sep 27 13:33:42 CEST 2011 [INFO] Final Memory: 53M/508M
[INFO] ------------------------------------------------------------------------

Resources