Hudson integration in NetBeans 6.7
By Petr Dvorak on Jun 17, 2009
Are you a Java developer and did you ever need to build your sources automatically? In this case, you must have already heard about Hudson... If you have used this tool, you must also know how great it is... But there is one more cool thing now (get ready to get excited). We have integrated Hudson in the NetBeans IDE 6.7.
But first things first for those who are not in the picture yet....
Briefly about Hudson - automate your builds
Hudson is a tool for continuous integration (CI) written in Java that runs as a server. It allows you to create a task ("Hudson job"...) that is executed either manually, or when some condition is valid, or periodically (in a given schedule). This job can be for example an Ant task - Hudson can be used for periodic building.
Furthermore, the version control systems are very well integrated with the Hudson - you can have one computer with running Hudson instance and some other computer with the source code repository where you and your team commit the sources. (These are typically not the computers that are used by developers.)
Build is performed on the computer with running Hudson instance (slaves can be configured for more complex building but let's keep it simple for now) and it is performed with all committed changesets. This means the resulting build artifact is more representative than the one that programmer has on his/her computer (as the local sources can be outdated).
Sample of how the architecture can look:
Hudson can be easily run on any computer with:
$ java -jar hudson.war
This launches a server on localhost (port 8080 by default). Hudson and Hudson jobs are easily configurable via the web interface...
More information about the Hudson CI Tool are online.
Hudson and NetBeans - making it even simpler
Since NetBeans 6.7, the Hudson Builders node is present in the services. You can easily create and manage some properties of the Hudson job.
Before you can create a Hudson job from IDE, you need to do following:
- Download Hudson and run it on some machine that you have access to
- ... so that you have a running Hudson instance ...
- ... so that the sources are on some well defined place ...
- ... so that the build can be performed - build cannot be successful if your project uses some libraries that Hudson does not have access to...
- ... otherwise you cannot even to run JUnit tests remotely ("junit.jar" library is needed)...
- Note: In order to make libraries sharable, open project properties, select "Libraries" section, click "Browse" button by the "Libraries Folder". Click "Next", click "Finish"...
Now how to create a Hudson job from the IDE:
- Register a Hudson instance in the IDE
- Open services view (Ctrl+4)
- Right-click the "Hudson Builders" node
- Invoke "Add Hudson Instance" action, fill in some alias for the instance and the URL
- Confirm the dialog - a new Hudson instance should be visible in the view (if there are some jobs on the instance, they are visible too)
- Create a new Hudson job (or "build"...)
- Right-click the Hudson instance you just added
- Invoke "New Build" action
- Fill in some alias for the build
- Browse for your NetBeans project
- Optionally, check what parts of the job should be performed (build Javadoc, run tests)
- Click the "Create" button - a new build will show up in the view
- Run the Hudson job
- Right-click the build you just created
- Invoke "Start job" action
- Expand the build's node - you will see a running instance of the job
- Right-click the running job and invoke console output - you can see the progress of the build that runs remotely (!) on the machine where the Hudson instance runs
How can you helps us?
Hudson integration is new in 6.7 and it definitely needs testing on various configurations. We are not able to test the Hudson integration in all scenarios - this is basically not technically possible. Your Hudson might use various authentication methods, your jobs can have specific configurations...
If you encounter any difficulties, you can submit an issue on the Hudson component and it will help us a lot (General: How do I file an issue?). You can provide a valuable feedback by writing comments on our mailing lists and forums. If you like the feature, help us to promote it, for example by writing some nice blog posts (if you intend to write an ugly one, please, file an issue first) or by spreading the word.