Utilize shell scripts,linux commands, open source tools,java, to Maximize the Power of Linux.
Focused on working with linux and shell, search engine technology including Chinese segmenter
Any questions please contact me at gmail: david.ullua

5/31/2007

Utilize hudson and ant to set up a daily build system step by step

Hudson is popular daily build system and a continuous integration engine. It is easy to setup and maintenance. Here's the brief introduction of the deploy process:

0). download hudson from https://hudson.dev.java.net/servlets/ProjectDocumentList.
You can download jnlp release jar or old release war package.

1).Hudson needs a web container such as glassfish, tomcat or winstone.
But Hudson ships with Winstone, so you can run it standalone by run : java -jar hudson.war, or java -jar hudson.jar if you downloaded the jnlp release.

Use the -D option to specify HUDSON_HOME in the invocation:
$ java -DHUDSON_HOME=/path/to/home -jar hudson.war

Alse you can use the environment variable:
$ export HUDSON_HOME=/path/to/hudson_home
$ java -jar hudson.war

HUDSON_HOME: Hudon needs some diskspace to perform builds and keep archives.
(By default, this is set to ~/.hudson , but you can change it: https://hudson.dev.java.net/admin.html)

2).If you don't have container yet, you can run hudson standalone (with shipped container Winstone), then you can access the portal of hudson by http://hostname:8080/ (default port is 8080), and create a new job, set some basic configurations. it will run by the schedule you configured.

3).If you have a container already (like tomcat), just deploy hudson.war to the webapps directory of tomcat, restart tomcat. then you can access the portal from http://hostname:8081/hudson, assume 8081 is the port for tomcat. for glassfish please take a reference at https://hudson.dev.java.net/containers/glassfish.html.

4). you can configure automatic build (like crontab), or periodical build or build by email, ref: https://hudson.dev.java.net/build.html

5). if you met problem when run ant task (), make sure your ant target is correct. My ant target is "-f CustomBuild.xml makepackage", it runs makepackage in ant build file CustomBuild.xml. If still fails, you can just checkout your project from repository to a clean directory, and run ant command to check whether it runs through, if fails check ant build file.

6).if can't send email successfully, just click "Manage Hudson" in the index page of the hudson portal, click "System Configuration" to configure smtp related info. If your SMTP need authentication, click "Advanced" in the "E-mail Notification" section, and enter the username plus password.

It should works, else email me your problem.

3 comments:

Anonymous said...

hudson plugins for check style,
(we save report to "reports" directory under the project's root dir)

find bugs:

1.check style:
mkdir reports\checkstyle
checkstyle.cmd -r src -f xml -c checkstyle_ruleset_minimal.xml -o reports/checkstyle/checkstyle-result.xml ,
save the content to run-checkstyle.cmd in the java web project root dir.

2.find bugs
rem classpath of auxclasspath should be like ./search/WEB-INF/lib/xxx-yy.jar,
rem the "./" prefix could not be deleted.

mkdir search\findbugs
findbugs -textui -auxclasspath .\search\WEB-INF\lib\spring.jar;.\search\WEB-INF\lib\commons-logging.jar;.\search\WEB-INF\lib\commons-dbcp -xml -outputFile reports\findbugs\findbugs-result.xml search/WEB-INF/classes

3.PMD
mkdir reports\pmd

pmd.bat src xml rulesets/pmd_ruleset_minimal.xml > reports\pmd\pmd-result.xml


then we can add 3 "execute windows batch command" for code analysis:

cmd.exe /C "run-checkstyle.cmd || echo checkstyle error"

cmd.exe /C "run-pmd.cmd || echo pmd error"

cmd.exe /C "run-findbugs.cmd || echo findbugs error"


finally, we can Publish JUnit test result report from "reports/junit-xml/*.xml",

Publish Checkstyle Analysis Results from "reports/findbugs/findbugs-result.xml"

Publish PMD Analysis Results from "reports/pmd/pmd-result.xml"

Anonymous said...

when using findbugs and there is many jars in auxclasspath, should use "" to quote the auxclasspath, as:
findbugs -textui -auxclasspath ".\search\WEB-INF\lib\spring.jar;.\search\WEB-INF\lib\commons-logging.jar;.\search\WEB-INF\lib\commons-dbcp.jar" -xml -outputFile reports\findbugs\findbugs.xml search/WEB-INF/classes

有馬記念 said...

有馬記念 2010を徹底予想!気になる枠順やオッズ情報はもちろん、今年は確実に当てにいきます

About Me

I am a senior developer and a team leader with 3 years development experience in Suzhou, China, focus on mobile web search, linux, Java and machine learning in NLP (natural language processing). My goal is to improve people's life with computer technology.