Friday 14 September 2007

Fixed: Maven 2 plugin problems with Bamboo/ Hudson + Tomcat setup on Windows

I've been tasked with setting up a continuous integration system at
work, and I've been evaluating - or trying to at least run - these
packages:

- Continuum
- Hudson
- Bamboo


I've yet to try these out:

- Luntbuild
- Cruisecontrol

From the looks of things, I proably should have tried out other two
before the other ones, given the lack of success I've had so far. :(

After a few emails exchanged with Atlassian Support re: Bamboo, I've
fixed a problem I was having with Bamboo and Hudson on my PC. I was
running them under Tomcat, which was installed as a Windows service.
My Ant builds were working fine, but my Maven2 builds were failing,
and would constantly complain that the 'maven-clean-plugin' was
missing, with errors like this:

Bamboo:

12-Sep-2007 16:48:01 [INFO]
----------------------------------------------------------------------------
12-Sep-2007 16:48:01 [INFO] Building AppFuse Core Application
12-Sep-2007 16:48:01 [INFO] task-segment: [clean, test]
12-Sep-2007 16:48:01 [INFO]
----------------------------------------------------------------------------
12-Sep-2007 16:48:01 [INFO] artifact
org.apache.maven.plugins:maven-clean-plugin: checking for updates from
appfuse
12-Sep-2007 16:48:02 [WARNING] repository metadata for: 'artifact
org.apache.maven.plugins:maven-clean-plugin' could not be retrieved
from repository: appfuse due to an error: Error transferring file
12-Sep-2007 16:48:02 [INFO] Repository 'appfuse' will be blacklisted
12-Sep-2007 16:48:03 [INFO]
------------------------------------------------------------------------
12-Sep-2007 16:48:03 [ERROR] BUILD ERROR
12-Sep-2007 16:48:03 [INFO]
------------------------------------------------------------------------
12-Sep-2007 16:48:03 [INFO] The plugin
'org.apache.maven.plugins:maven-clean-plugin' does not exist or no
valid version could be found
12-Sep-2007 16:48:03 [INFO]
------------------------------------------------------------------------
12-Sep-2007 16:48:03 [INFO] For more information, run Maven with the -e switch
12-Sep-2007 16:48:03 [INFO]
------------------------------------------------------------------------
12-Sep-2007 16:48:03 [INFO] Total time: 1 second
12-Sep-2007 16:48:03 [INFO] Finished at: Wed Sep 12 16:48:03 EST 2007
12-Sep-2007 16:48:03 [INFO] Final Memory: 1M/?4M
12-Sep-2007 16:48:03 [INFO]
------------------------------------------------------------------------

HUDSON:

[struts2-starter] $ C:\javatools\maven-2.0.6\bin\mvn.bat package
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building Struts 2 Starter
[INFO] task-segment: [package]
[INFO] ----------------------------------------------------------------------------
[INFO] artifact org.apache.maven.plugins:maven-resources-plugin:
checking for updates from central
[WARNING] repository metadata for: 'artifact
org.apache.maven.plugins:maven-resources-plugin' could not be
retrieved from repository: central due to an error: Error transferring
file
[INFO] Repository 'central' will be blacklisted
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-resources-plugin'
does not exist or no valid version could be found


I had already come across an issue raised for Hudson concerning this,
but didn't completely figure out what it meant:

https://hudson.dev.java.net/issues/show_bug.cgi?id=470

"The current workaround is to have hudson run under a new user with
its own .m2 directory and have whichever profiles are necessary
activated by default. That way, the profiles are picked up as part of
the alignWithUserInstallation mechanism in the embedder."

Atlassian support was able to replicate the error I was getting by
running the Bamboo standalone running under the SYSTEM directory, and
asked me to check if Tomcat was running as SYSTEM, which it was, as I
that is the default when you install Tomcat as a Windows service.
Ah, of course! <lightbulb moment>

When these packages do their continous integration, Bamboo and Hudson
are calling outside the web application to an external batch file. So
when Maven gets run by Bamboo or Hudson, Maven will run as *that*
user, which in this case is the SYSTEM user. I guess SYSTEM user will
try to get its settings from C:\Documents and Settings\Default User\
and not my own user account with the correct maven settings.

So the solution was to go into Services, look for "Apache Tomcat" then
in the "Log On As" column, get it to run as a user with the correct
Maven settings.

Now I don't know if I would have gotten this problem if I was running
under Linux. I think I would still have, because if Tomcat was running
under the user "tomcat", but my maven settings were under a
"autobuild" directory, it would be the same scenario, and the fix
would be to run Tomcat - or whatever app server you're using - under
the "autobuild" account.

1 comment:

Jon Silvers said...

Sorry to hear you ran into problems with the Bamboo eval. Hopefully it's smoother sailing from here on out. Let us know what system you decide to go with!