This section contains general information on How To do stuff with Hudson. While the Main Hudson wiki page is a good starting point, it can leave a lot to be desired at times. This section will cover specific eclipse project use cases.
- 1 HOW DO I....
- 1.1 Retrieve files from the Last Successful build and use them in the next?
- 1.2 How do I get a ZIP of all the artifacts produced during a build.
- 1.3 Is there an API?
- 1.4 What URLs provide a RESTful interface?
- 1.5 How do I get a List of Artifacts from the Last Successful Build
- 1.6 Monitor my SVN repository for changes if sub-directories have their own trunk, branches, tags?
- 1.7 benchmark a build
HOW DO I....
The purpose of this page is to provide a brief introduction on how to do various things with Hudson. With the number of plugins available and the number of different ways to configure your job for eclipse, it can get confusing. This page will provide some brief examples and links to ease the learning curve.
Retrieve files from the Last Successful build and use them in the next?
Each build has it's Last Successful Successful build available as a RESTful url. The format for this is:
Replace JOBNAME with the name of the job that you are interested. Any of the artifacts may be accessed and retrieved by giving the full path to its location. To retrieve a specific ZIP file from a Athena produced build one could use something like:
This would GET the file wst-xsl-SDK-N2000912121209.zip from the build. See Athena's option for creating SNAPSHOTS to create standardized names to make automated retrieval easier.
The following build urls can always be accessed via RESTful API:
- Last Successful
- Last Stable
- Last Build
- Last Failed Build
How do I get a ZIP of all the artifacts produced during a build.
You'll need to make sure that your job is configured to Archive your build artifacts. Once a build produces archived artifacts, you can use the All Files in Zip link to produce and retrieve a zip. The Zip file will have a name of archive.zip.
For example, to get all the artifacts produced by the XSL job for the last successful build you can visit the following link:
This works for workspaces, last successful build, last build, last stable build, and last build failure. Just make sure to access the artifact url.
Is there an API?
Yes. Hudson provides RESTFul style API for working with the system. You can use this API during your build to automated various portions. For example, retrieve a list of all the artifacts from the Last Successful Build. You may also access any of the artifacts via the URL for that artifact. This allows all a platform independent way to retrieve files from one build and reuse them in another build.
- RESTFul API - retrieve and access files via RESTful web services in XML, JSON or Python data formats.
What URLs provide a RESTful interface?
Most of the existing URLs will provide a RESTful interface by adding /api on the end of the url. By appending it with xml, json, or python you can retrieve the information in those data formats. XML RESTful also leverages the power of XPath to allow filtering of the data retrieved. See HUDSON's remote API documentation for more information. All Hudson RESTFul API's are backed by an XML Schema so data binding can be done.
Almost any of the URL's available on HUDSON can be accessed restfully. You can experiment with adding the /api method to the end of the URL name.
How do I get a List of Artifacts from the Last Successful Build
You can get a list of artifacts in XML format by accessing your JOB's last succesful build permanent URL and adding /api/xml to the end. For example.
https://hudson.eclipse.org/hudson/job/cbi-wtp-wst.xsl/lastSuccessfulBuild/api/xml will retrieve an XML formatted file that contains information about the last successful build. You can then use this file as input to a program or a build script to retrieve the artifacts from the build.
See the Linux Tools project's build job configuration or their release engineering page starting at this section step 9.
benchmark a build
Sometimes builds take a long time, and you would like to benchmark each step of the build. If using a shell script, you can do something like this for each step:
before="$(date +%s)" # build step X here echo "step X took : $(expr $(date +%s) - $before)s"