Building Jenkins

Skip to end of metadata
Go to start of metadata

Prerequisites

Building Jenkins requires at minimum, a fairly recent version of JDK 1.6 (JRE will not suffice, and there are reports indicating that 6u17 was not sufficiently new), as well as Maven (3.0.4+).
Looks like the Maven Enforcer plugin apparently looks at your JAVA_HOME environment variable. Here is a small linux alias I used to switch to jdk 1.6:

alias jdk6='export JAVA_HOME=$JAVA_6_HOME ; export PATH=$JAVA_6_HOME/bin:$PATH'

Issues:

  • Test suite requires a graphical environment.

Configure work environment

To checkout Jenkins, follow the steps below. Then run Maven build at least once to have it generate additional source files:

// check out the workspace
$ git clone https://github.com/jenkinsci/jenkins.git
// Download dependencies and build with Maven
// Note: mvn install may be a prerequisite for other mvn targets
$ cd jenkins
$ mvn -Plight-test install

The git repository mentioned above is where the core of Jenkins is located, i.e. not the plugins. In the root of the repository is a file called changelog.html, which you should update if/when you become a committer.

The first build will take a while, because it has to download all needed dependencies and plugins from Maven central.
If it succeeds with BUILD SUCCESSFUL at the end, you are good to go.
At the end you should have war/target/jenkins.war, which is the Jenkins you just built.

Building and running tests can cause permgem errors. If that is the case, try to increase the JVM limit for Maven targets, by setting the following environment variable:
$ export MAVEN_OPTS="-XX:MaxPermSize=128m"

Eclipse

You can either use M2Eclipse/m2e to import the Maven projects directly or create Eclipse project files from the command line and then import the projects into Eclipse. There's no consensus in the community as to which approach is better. Experienced Maven users seem to prefer m2eclipse, but people new to Maven seem to find the latter easier and more predictable. For the latter do:

// generate .project and .classpath for Eclipse
$ mvn -DdownloadSources=true eclipse:eclipse

There is a step-by-step guide to working with Eclipse once you've run the above commands.

NetBeans/Intellij IDEA

NetBeans (6.7+) users can just open the POM directly, with File -> Open Project and navigate to the jenkins folder. IntelliJ IDEA users can directly open a Maven POM.

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.
If IntelliJ IDEA fails to compile with error messages "XXX clashes with package of same name", this is caused by issue IDEA-80331. JetBrains suggest to add resources:*.groovy to Settings | Compiler | Resource Patterns as a workaround.

Debugging Jenkins

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 Jenkins under the debugger, and open http://localhost:8080/ in your browser:

# To change the port run mvnDebug hudson-dev:run -Dport=9090
$ cd war
$ mvnDebug 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.

If you are developing plugins and want to test them see Plugin Structure#Testing With Jenkins

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 $JENKINS; mvn clean install".
  3. The above mentioned profile (-Plight-test) does only run the fairly quick unit tests and leaves out the integration test in the test-harness module. If you want to skip all tests (not recommended!), run Maven with "-Dskip-test-harness".
  4. If you have trouble that isn't addressed here, please send email to the Jenkins dev list. The developers all read that list frequently. You might not get an answer for a long time - or not at all - if you post your questions as comments to this page.
  5. Setting up a local Maven repository manager can considerably speed up your Jenkins builds, and make life with Maven more pleasant in general. Please click here for Artifactory or here for Nexus instructions.
  6. Use can also use Artifctory for easy and rapid setup for hackatons and meetups.

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
Open-source license for StackProbe Profiler
StackProbe is kindly supporting open source projects with its profiler, StackProbe Profiler
Open-source license for IntelliJ IDEA
JetBrains is kindly supporting open-source projects with their OSS license for IntelliJ IDEA.
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Add Comment