Quick Tutorial: Hudson and Artifacts

I really like using Hudson ! It is amazing what magic you can do with it, even some stuff is simple, like the “Archive the artifacts” feature. Dont you have the same situation: Some build running on some server will create an error that you can’t see in you current codebase. Would be nice to get exact the sourcecode and deployment that belongs to this build ? I keep the workspace (sourcecode excluding the build folder and .svn folder) with the 2 steps below.

Hudson Job (artifacts)

rm BACKUP*.gz
tar -cvf BACKUP_SRC_$BUILD_NUMBER.tar --exclude 'build/*' --exclude 'dist/*' --exclude '.svn' {your_project_name}
gzip *tar
{your_project_name}/dist/*.war , *.gz

Build Artifacts

Why exlude .svn ?

  • The hidden folders come with lots of extra files that just add to you tar file size. You can easily reduce by 30% by not keeping them.
  • If you unpack the project later it is an uncontrolled/un-svn’d project and your IDE (like Netbeans) would not start to do updates on it, or you committing old source files. It is just meant for investigation !

Why rm backup file ?

  • Each artifact filename carries the build number as filename, if we dont remove, every build will collect all previous backup files as artifact.


  • You should take care of the diskspace consumption ! A serious web project (with libraries) can easily tar/gzip into a 100 MB file. If you do a few builds a day…
    An option is to ftp the files somewhere and/or have a cronjob to clean up. Maybe you only want to keep sourcecode that is in production somewhere.
  • The artifacts options is ALWAYS executed, even your build was NOT successful.

Update 2010-07-28:

  • Yes, you are right saying, I could retrieve the same source code release by checking out the related revision.

Check out from SVN

Check out from SVN (revision)

One thought on “Quick Tutorial: Hudson and Artifacts

  1. Pingback: Hudson saves Artifacts to Amazon S3 « The JavaDude Weblog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s