Building Hudson

Building Hudson requires JDK1.6.x and Maven 2.x (If using a 2.0.x release, then 2.0.6 or greater is required) .

Issues:

To build Hudson so that you can make modifications, follow the steps below:

// check out the workspace
$ svn co https://svn.dev.java.net/svn/hudson/trunk/hudson
$ svn co https://svn.dev.java.net/svn/hudson/trunk/www
$ cd hudson
// use maven2 for build
$ mvn install

If you just want to build the core without all the plugins, do:

 $ cd hudson/main
 $ mvn install

If it asks for username/password, you can either use your java.net ID, or simply specify "guest" as the user name and empty password.
The trunk/hudson directory is where the Hudson product itself is located -- all the source, etc.   The trunk/www directory is information for the Hudson website and contains changelog.html, which you should update if/when you become a committer.

To check out the hudson sources, first install Subversion. When 'svn' is available on the path Maven can be used to get the Hudson sources. This is the maven command to run:
mvn scm:checkout -DconnectionUrl=scm:svn:https://svn.dev.java.net/svn/hudson/trunk/hudson -DcheckoutDirectory=hudson
mvn scm:checkout -DconnectionUrl=scm:svn:https://svn.dev.java.net/svn/hudson/trunk/www -DcheckoutDirectory=www
This command will create a subdirectory 'hudson' from the directory where you run the command.

The first build will take a while, because it has to download million jars from all over the world. You'll also need to have Java6 to build Hudson (even though Hudson will run on Java5. Mac users, Java 6 is only available for Core 2 Duo machines - see http://landonf.bikemonkey.org/2009/05/17#OpenJDK6_MacPorts.20090516 for a beta of OpenJDK for 10.4 and 10.5)
If it succeeds with BUILD SUCCESSFUL at the end, you are good to go.

If the build failed with the following messages:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
It may be that you are not using Java6.

At the end you should have hudson/main/war/target/hudson.war, which is the hudson you just built.

If you are building behind a http proxy, you will need to use Maven 2.0.5 or newer as there is a well known bug fetching artifacts from a https:// repository via a http proxy with Maven 2.0.4.
Currently, Due to a bug in javac, the build may fail with the following error. If you hit this, try rebuilding it without doing 'clean'.
The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2964)
at com.sun.tools.javac.code.Types.adapt(Types.java:2995)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2956)
.......
.........
INFO ------------------------------------------------------------------------
ERROR BUILD ERROR
INFO ------------------------------------------------------------------------
INFO Fatal error compiling

It has been reported that setting MAVEN_OPTS to include "-Xmx177M" before invoking NetBeans allows Hudson to build.  For OS X this can be done in Terminal.app with

export MAVEN_OPTS="-Xmx177M"
open /Applications/NetBeans/NetBeans\ 6.7.app 
 

If on "mvn clean" you get this error

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) org.jvnet.hudson.plugins.hudsontrayapp:client:jar:0.7.3-SNAPSHOT

  Try downloading the file manually from the project website.

you can work around this by doing a mvn install in plugins/hudsontrayapp


Configure work environment

To work on the Hudson code productively, you should generate your IDE project files (note: these commands run maven offline (i.e. -o), which is faster but might not work correctly if you have not just run a "mvn install"):

// if you are using IntelliJ
$ mvn -DdownloadSources=true idea:idea
// if you are using Eclipse
$ mvn -DdownloadSources=true eclipse:eclipse

NetBeans (6.7+) users can just open the module directly,  with File -> Open Project and navigate to the hudson folder. 

There is a step-by-step guide to working with Eclipse once you've run the above commands. Due to a bug in Eclipse, Eclipse users may need to remove src/main/resources from the source folder list after projects are imported to the workspace. See this e-mail thread for more details.

If your IDE complains that 'Messages' class is not found, they are missing because they are supposed to be generated. Run a Maven build once and you should see them all. If that doesn't fix the problem, make sure your IDE added target/generated-sources to the compile source roots.

Debugging Hudson

Maven Jetty plugin offers a convenient debugging environment, but for a few reasons we maintain a modified version of the plugin under a different name, so the plugin name is different but the configuration parameters are the same. Do the following to run Hudson under the debugger, and open http://localhost:8080/ in your browser:

$ cd main/war
$ export MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n"
$ mvn hudson-dev:run

This will launch maven with the debugger port for 8000. You can connect to this port from your IDE by using the remote debug feature. Once this starts running, keep it running. Jetty will pick up all the changes automatically.

  1. When you make changes to view files in core/src/main/resources, just hit F5 in your browser to see the changes.
  2. When you make changes to static resources in war/resources, just hit F5 in your browser to see the changes.
  3. When you change Java source files. Compile them in your IDE and Jetty should pick that up. You don't need to run mvn at all for this.
  4. NetBeans users can just hit Debug with main/war open.

Other Tips

  1. Consider running Maven like mvn -o ... to avoid hitting repositories every time. This will make various operations considerably faster.
  2. When Maven complains about something, try "cd $HUDSON/main; mvn clean install".
  3. If you don't want to waste time running tests, run Maven with "-Dmaven.test.skip=true" to skip tests.
  4. If you have trouble that isn't addressed here, please send email to the Hudson dev list. The developers all read that list frequently. You might not get an answer for a long time if you post your questions as comments to this page.

Credits

The sponsor statement from YourKit Java Profiler, which gave us a free license for the Hudson project.

Open-source license for YourKit Java Profiler
YourKit is kindly supporting open source projects with its full-featured Java Profiler. YourKit, LLC is creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products: YourKit Java Profiler and YourKit ASP.NET Profiler


Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.
  1. Jul 08, 2008

    Karl Palsson says:

    Under debugging hudson, have you got any advice on how to debug plugins?

    Under debugging hudson, have you got any advice on how to debug plugins?

    1. Aug 26, 2008

      Kohsuke Kawaguchi says:

      See Plugin tutorial for how to develop and debug plugins.

      See Plugin tutorial for how to develop and debug plugins.

  2. Nov 18, 2008

    Philippe Martel says:

    [content removed by the poster]

    [content removed by the poster]

  3. Nov 26, 2008

    yongjun says:

    I have a question about the IDE eclipse. I followed the build steps and download...

    I have a question about the IDE eclipse. I followed the build steps and downloaded hudson source codes. If I use eclipse3.2, build always failed. The common error is 'some type is collides with a package". Then I change to eclipse3.4, there are still some compile errors but I can deal with them finally.

    So Kohsuke, may you suggest which IDE we can use for hudson development? 

    BTW, I am in solaris 10, x86. The top support Eclipse version is 3.2.

    Thank you very much.

  4. Jun 09, 2009

    Pete says:

    Recently I have had issues with building.  If I do this before hand, it wor...

    Recently I have had issues with building.  If I do this before hand, it works fine. 

    # 177 used below is the minimum, using 256M would allow for future needs.
    
    MAVEN_OPTS="-Xmx177M"
    mvn -Dmaven.test.skip=true install  
    
  5. Sep 01

    Eric Badiere says:

    This is my first attempt at building hudson and I am getting the following when ...

    This is my first attempt at building hudson and I am getting the following when I run 'mvn -o install' :

     [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] Internal error in the plugin manager executing goal 'org.jvnet.hudson.tools:maven-hpi-plugin:1.31:apt-compile': Unable to find the mojo 'org.jvnet.hudson.tools:maven-hpi-plugin:1.31:apt-compile' in the plugin 'org.jvnet.hudson.tools:maven-hpi-plugin

    Any help wold be appreciated.

  6. Oct 14

    Clifton Craig says:

    I get a compile error when building from source: [INFO] [stapler:apt-compile] ...

    I get a compile error when building from source:

    [INFO] [stapler:apt-compile]

    [INFO] Compiling 561 source files to /Users/cliftoncraig07/java-apps/Hudson-src/hudson/main/core/target/classes

    [INFO] ------------------------------------------------------------------------

    [ERROR] BUILD ERROR

    [INFO] ------------------------------------------------------------------------

    [INFO] Fatal error compiling

    Embedded error: Error while executing the external compiler.

    error=2, No such file or directory

    [INFO] ------------------------------------------------------------------------

    [INFO] For more information, run Maven with the -e switch

    [INFO] ------------------------------------------------------------------------

    [INFO] Total time: 1 minute 31 seconds

    [INFO] Finished at: Wed Oct 14 19:07:23 EDT 2009

    [INFO] Final Memory: 65M/81M

    [INFO] ------------------------------------------------------------------------

    cliffmac:main cliftoncraig07$ javac -version

    javac 1.6.0_13

  7. Dec 02

    Lucky Luke says:

    Hi I am releatively new to Hudson. I get the following error when i try to run ...

    Hi

    I am releatively new to Hudson. I get the following error when i try to run mvn -e install -Dmaven.test.skip=true

    .

    .

    .

    .

    .

    [INFO] [enforcer:display-info

    Unknown macro: {execution}

     

    ]
    [INFO] Maven Version: 2.1.0
    [INFO] JDK Version: 1.6.0_13 normalized as: 1.6.0-13
    [INFO] OS Info: Arch: x86 Family: windows Name: windows xp Version: 5.1
    [INFO] [site:attach-descriptor]
    [INFO] [install:install] 

    .

    .

    .

    .

     [resolveArtifact] Copying C:\Documents and Settings\rajesh.nair\.m2\repository\c
    om\sun\winsw\winsw\1.8\winsw-1.8-bin.exe to D:\Java\EclipseWorkspace\svn\hudson{color}
    trunk\hudson\main\core\target\classes\windows-service\hudson.exe
    [INFO] Executed tasks
    [INFO] [resources:resources]
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 2432 resources
    [INFO] [stapler:apt-compile]
    [INFO] Compiling 583 source files to D:\Java\EclipseWorkspace\svn\hudson\trunk\h
    udson\main\core\target\classes
    [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Compilation failure

    D:\Java\EclipseWorkspace\svn\hudson\trunk\hudson\main\core\src\main\java\hudson{color}
    os\windows\ManagedWindowsServiceLauncher.java:[51,0] cannot access org.kohsuke.j
    interop.JIProxy
    class file for org.kohsuke.jinterop.JIProxy not found
    import static org.jvnet.hudson.wmi.Win32Service.Win32OwnProcess;

    D:\Java\EclipseWorkspace\svn\hudson\trunk\hudson\main\core\src\main\java\hudson{color}
    os\windows\ManagedWindowsServiceLauncher.java:[51,0] cannot access org.kohsuke.j
    interop.JIProxy
    class file for org.kohsuke.jinterop.JIProxy not found
    import static org.jvnet.hudson.wmi.Win32Service.Win32OwnProcess;

    D:\Java\EclipseWorkspace\svn\hudson\trunk\hudson\main\core\src\main\java\hudson{color}
    os\windows\ManagedWindowsServiceLauncher.java:[140,64] cannot find symbol
    symbol  : method cast(java.lang.Class<org.jvnet.hudson.wmi.Win32Service>)
    location: interface org.jvnet.hudson.wmi.SWbemObject

    D:\Java\EclipseWorkspace\svn\hudson\trunk\hudson\main\core\src\main\java\hudson{color}
    os\windows\ManagedWindowsServiceLauncher.java:[145,24] cannot find symbol
    symbol  : variable Win32OwnProcess
    location: class hudson.os.windows.ManagedWindowsServiceLauncher

    [INFO] ------------------------------------------------------------------------
    [INFO] Trace
    org.apache.maven.BuildFailureException: Compilation failure
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
    ultLifecycleExecutor.java:699)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
    fecycle(DefaultLifecycleExecutor.java:540)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
    ltLifecycleExecutor.java:519)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
    dleFailures(DefaultLifecycleExecutor.java:371)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
    ts(DefaultLifecycleExecutor.java:332)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
    fecycleExecutor.java:181)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
            at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
            at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

            at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
    Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation fail
    ure
            at org.kohsuke.stapler.AbstractCompilerMojo.execute(AbstractCompilerMojo
    .java:508)
            at org.kohsuke.stapler.CompilerMojo.execute(CompilerMojo.java:111)
            at org.kohsuke.stapler.AptMojo.execute(AptMojo.java:21)
            at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
    nManager.java:483)
            at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
    ultLifecycleExecutor.java:678)
            ... 16 more

    Can someone help me figure out what I am doing wrong?

    Thanks,

    LL

  8. Dec 18

    Russ Hickingbottom says:

    Ummm... I get an error on the very first step. Using svn at the CLI I get "svn:...

    Ummm... I get an error on the very first step.

    Using svn at the CLI I get "svn: OPTIONS of 'https://svn.dev.java.net/svn/hudson/trunk/hudson': could not connect to server (https://svn.dev.java.net)"

    I am behind a firewall here at work so I am looking into that but is there a possibility this url is incorrect?

    Thanks,

    Russ

    1. Dec 18

      Russ Hickingbottom says:

      OK nevermind - it was the proxy after all.  I had to set it up in my server...

      OK nevermind - it was the proxy after all.  I had to set it up in my servers file for Subversion.