Jump to: navigation, search

Difference between revisions of "Hudson/HowTo"

m (Retrieve files from the Last Successful build and use them in the next?)
Line 59: Line 59:
  
 
See the Linux Tools project's build job configuration or their release engineering page starting at [http://wiki.eclipse.org/Linux_Tools_Project/Releng#Build-related_checklist this section] step 9.
 
See the Linux Tools project's build job configuration or their release engineering page starting at [http://wiki.eclipse.org/Linux_Tools_Project/Releng#Build-related_checklist 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"

Revision as of 11:31, 10 September 2010

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.


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:

https://build.eclipse.org/hudson/job/JOBNAME/lastSuccessfulBuild/artifact/

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:

https://build.eclipse.org/hudson/view/WTP/job/cbi-wtp-wst.xsl/lastSuccessfulBuild/artifact/build/athena/wst-xsl-SDK-N200912121209.zip

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:

https://build.eclipse.org/hudson/view/WTP/job/cbi-wtp-wst.xsl/lastSuccessfulBuild/artifact/*zip*/archive.zip

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://build.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.

Monitor my SVN repository for changes if sub-directories have their own trunk, branches, tags?

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"